Click here to Skip to main content
15,913,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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,
C#
protected void grdview_RowEditing(object sender, grdviewEventArgs e)
        {
            try
            {
                if(text!="")
                {
                    ImageButton imgbtnexm5 =(ImageButton)grdview.Rows[e.NewEditIndex].FindControl("imgbtnexm5");
                    imgbtnexm5.Visible = true;
                }
}
}


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.
C#
<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.
Posted

Hi,

Better You would have the control in Edit template, that would be visible automatically in edit status .
XML
<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>
 
Share this answer
 
Comments
girish sp 11-Nov-11 5:14am    
my code only worked,thanks for ur help
hi ,
i pasted my code in other system n it worked,

thanks anyways
 
Share this answer
 
v2
Comments
RaviRanjanKr 11-Nov-11 5:16am    
You should post as a Comment by using Have a Question or Comment Instead of posting as an Answer :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900