开发者

how to display result in gridview according to textbox only if textbox2 value is greater than textbox1?

how to display result in gridview according to textbox only if textbox2 date value is g开发者_运维百科reater than textbox1 ?

i have two textboxes and gridview ... if i type in Textbox1 : 2-Jan-2011 and in textbox2 : 1-Jan-2011 then in label1 the eroor message display else ..if textbox2 value is greater then textbox1 value then gridview will display records according to textbox1 and textbox2 from database ...

how to do that ,,, ?


Function to retrieve date parameters and either show error message or call Binding function:

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
  } 
}

Function to bind the data:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜