C# 如何在Gridview中访问特定标签文本
我在C# 如何在Gridview中访问特定标签文本,c#,asp.net,gridview,C#,Asp.net,Gridview,我在GridView1的EditItemTemplate中使用以下代码 <EditItemTemplate> <asp:Label ID="Label1" runat="server" Text="<%# bind('ftype') %>"></asp:Label> <asp:Label ID="Label2" runat="server" Text="<%# bind('ftname') %>"></
GridView1
的EditItemTemplate
中使用以下代码
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text="<%# bind('ftype') %>"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="<%# bind('ftname') %>"></asp:Label>
<asp:Label ID="Label3" runat="server" Text="<%# bind('fsname') %>"></asp:Label></br>
<asp:Label ID="Label4" runat="server" Text="<%# bind('fa1') %>"></asp:Label></br>
<asp:Label ID="Label5" runat="server" Text="<%# bind('fa2') %>"></asp:Label></br>
<asp:Label ID="Label6" runat="server" Text="<%# bind('fa3') %>"></asp:Label></br>
<asp:TextBox ID="TextBox1" Width="30px" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" Width="30px" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox3" Width="30px" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox4" Width="30px" runat="server"></asp:TextBox>
</EditItemTemplate>
如何访问Gridview
中任何标签的文本
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
Label label = (Label)this.GridView1.Rows[e.NewEditIndex].FindControl("Label4");
string value = label.Text;
}
请分享您的行编辑功能我已经编辑了我的答案请检查此项。
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
Label label = (Label)this.GridView1.Rows[e.NewEditIndex].FindControl("Label4");
string value = label.Text;
}