在datagrid中,通过findcontrol引用的控件能否设置控件属性?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If Not IsPostBack Then
strconn = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data-lilun.mdb")
ada = New OleDbDataAdapter("SELECT 题号,题目,A,B,C,D,答案 FROM tiku where 卷号='" & ListBox1.SelectedValue & "'", strconn)
ada.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
DataGrid1.DataBind()
End If
End Sub
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
strconn = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data-lilun.mdb")
ada = New OleDbDataAdapter("SELECT 题号,题目,A,B,C,D,答案 FROM tiku where 卷号='" & ListBox1.SelectedValue & "'", strconn)
ada.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
DataGrid1.DataBind()
End Sub
Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Unload
ada.Dispose()
ds.Dispose()
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
DataGrid1.CurrentPageIndex = DataGrid1.CurrentPageIndex
strconn = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data-lilun.mdb")
ada = New OleDbDataAdapter("SELECT 题号,题目,A,B,C,D,答案 FROM tiku where 卷号='" & ListBox1.SelectedValue & "'", strconn)
ada.Fill(ds)
DataGrid1.DataSource = ds.Tables(0)
DataGrid1.DataBind()
If e.CommandName = "show" Then
CType(e.Item.FindControl("Tx"), TextBox).Visible = False
Response.Write(CType(e.Item.FindControl("Tx"), TextBox).Text)
End If
End Sub
在itemcommand中response能输出控件的text,当不能设置其属性,那位能给我看看,谢谢了?