简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM