如果textbox2值大于textbox1,如何根据文本框在gridview中显示结果?

时间:2011-01-26 06:52:15

标签: asp.net vb.net visual-studio-2008

如果textbox2日期值大于textbox1,如何根据文本框在gridview中显示结果?

我有两个文本框和gridview ...如果我输入Textbox1:2011年1月2日和文本框2:2011年1月1日然后在label1中eroor消息显示else ..if textbox2值大于textbox1值然后gridview将根据来自数据库的textbox1和textbox2显示记录...

该怎么做,,,?

1 个答案:

答案 0 :(得分:2)

检索日期参数并显示错误消息或调用绑定功能的函数:

private void LoadData() {
  try {
    DateTime date1 = Convert.ToDateTime(TextBox1.Text);
    DateTime date2 = Convert.ToDateTime(textbox2.Text);
    if (date1 >= date2) {
      label1.Text = "Invalid Dates";
    } else {
      BindDataInGridview(date1, date2);
    }
  } Catch (Exception ex) {
    // log and report exception
  } 
}

绑定数据的功能:

private void BindDataInGridview(DateTime date1, DateTime date2) {
  // Logic to retrieve your data based on date parameters and bind it to the GridView
}