如何根据文本框文本禁用gridview中的每个项目?

时间:2010-12-21 10:00:29

标签: asp.net vb.net

alt text

如果预订关闭列值等于或大于textbox1文本,那么gridview中的book按钮将被禁用,每个gridview项目的预订关闭时间更长且等于textbox1时间..

怎么做?

M使用VS 2008和vb

1 个答案:

答案 0 :(得分:1)

您应该在GridView的rowbound事件处理程序中处理此问题。

更新#1

protected void books_RowDataBound(object sender, GridViewRowEventArgs e) {
            if(e.Row.RowType == DataControlRowType.DataRow) {

                //Do this only if the textbox value is ....
                Button btn =  (( GridView )sender).FindControl("button");
                btn.Enabled = false;
            }
        }

更新#2

Protected Sub books_RowDataBound(sender As Object, e As GridViewRowEventArgs)
 If e.Row.RowType = DataControlRowType.DataRow Then

  'Do this only if the textbox value is ....
  Dim btn As Button = DirectCast(sender, GridView).FindControl("button")
  btn.Enabled = False
 End If
End Sub