【问题标题】:how to display result in gridview according to textbox only if textbox2 value is greater than textbox1?仅当 textbox2 值大于 textbox1 时,如何根据文本框在 gridview 中显示结果?
【发布时间】:2011-01-26 06:52:14
【问题描述】:

只有当textbox2日期值大于textbox1时,如何根据textbox在gridview中显示结果?

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

如何做到这一点,,,?

【问题讨论】:

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


    【解决方案1】:

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

    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
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-12
      相关资源
      最近更新 更多