62,025
社区成员
发帖
与我相关
我的任务
分享
<asp:gridview id="GridView1" runat="server" cellpadding="4" forecolor="#333333" gridlines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:TextBox id="TextBox1" runat="server" text="TextBox" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
<asp:button id="Button1" runat="server" text="Button" onclick="Button1_Click" />
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strIDs = "1,2,3,4,7";
s tring[] aList = strIDs.Split(',');
this.GridView1.DataSource = aList;
this.GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow gr in this.GridView1.Rows)
{
TextBox tb = gr.FindControl("TextBox1") as TextBox;
if (tb != null)
{
tb.Enabled = false;
}
}
}