我在EditItemTemplate
的{{1}}中使用了以下代码。
GridView1
现在在我的<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>
函数中,我想访问GridView1_RowEditing
文本。我使用Label4
,但只找到控件而没有返回文本。
FindControl
如何访问protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
Label Label1 = (Label)GridView1.FindControl("Label4");
if (Label1.Text == null)
{
//some code
}
}L
中存在的text
个label
?
答案 0 :(得分:0)
使用此,
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
Label label = (Label)this.GridView1.Rows[e.NewEditIndex].FindControl("Label4");
string value = label.Text;
}