使控件在gridview asp.net页中可见 [英] making control visible in gridview asp.net page
问题描述
我在gridview中有一个控件,该控件在设计中使visible = false,我在项目模板中添加了该控件.并在grdview_RowEditing事件中使该控件可见为真,
Hi,
i have a control in gridview which i have made visible=false in design,i have added that control in item template. and in grdview_RowEditing event i want to make that control visible true,
protected void grdview_RowEditing(object sender, grdviewEventArgs e)
{
try
{
if(text!="")
{
ImageButton imgbtnexm5 =(ImageButton)grdview.Rows[e.NewEditIndex].FindControl("imgbtnexm5");
imgbtnexm5.Visible = true;
}
}
}
但该控件不可见,
注意:我已在项目模板中添加了控件,并试图在编辑事件中使可见性为真,并且我尝试将其添加到编辑模板中,但我根本找不到控件.可能是因为该行尚未被编辑.
问:如何使该控件在RowEditing事件中可见,以及应在哪个模板中添加该控件.
but that control is not visible,
Note:i have added the control in item template,and trying to make the visibility true in edit event,and also i tried adding it in edit template but i wont find the control at all.may be because the row is not yet edited.
Q:how do i make the control visible in RowEditing event,and which template should i add the control.
<itemtemplate>
<asp:Label ID="lblDate" runat="server" Text='<%# Bind("Date") %>'>
<asp:ImageButton ID="imgbtnexm5" runat="server" ImageUrl="~/images/myimage.gif" Visible="false"/>
</itemtemplate>
在此先感谢.
thanks in advance.
推荐答案
更好您将在Edit模板中拥有该控件,该控件将在编辑状态下自动显示.
Hi,
Better You would have the control in Edit template, that would be visible automatically in edit status .
<asp:TemplateField HeaderText="Name" SortExpression="FirstName">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("FirstName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server"
Text='<%# Bind("FirstName") %>'></asp:Label>
<asp:Label ID="Label2" runat="server"
Text='<%# Eval("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
我将代码粘贴到其他系统中了,
还是谢谢
hi ,
i pasted my code in other system n it worked,
thanks anyways
这篇关于使控件在gridview asp.net页中可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!