Problem with add linkbutton to a footer of a gridview runtime!!!
-
I use the following code to add linkbutton to footer of a grideview, but it cause error sometimes!!!!! In my computer as local server it works, but another users see the error.
LinkButton lbtn = new LinkButton();
lbtn.Text = " |< ";
Panel pnl = GridView1.FooterRow.FindControl("pnlFooter") as Panel ;
lbtn.CommandArgument = (pageindex).ToString();
lbtn.Command += new CommandEventHandler(lbtn_Command);
pnl.Controls.Add(lbtn);the error accurs at line
Panel pnl = GridView1.FooterRow.FindControl("pnlFooter") as Panel ;
what could I do to solve it?!!!! :doh: any help would be useful!! HTML For footer gridview:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="False" GridLines="None" ShowHeader="False" onpageindexchanged="GridView1_PageIndexChanged" ShowFooter="True" FooterStyle-Font-Bold="True">
<Columns>
asp:TemplateField
<ItemTemplate>
<table style="width:100%">
<tr>
<td><!-- <asp:LinkButton Text='<%# Eval("Title") %>' ID="libtnGRV" CommandArgument='<%# Eval("URLProduct") +"&Companyurl="+ Eval("URLCompany")%>' runat="server" oncommand="libtnGRVcommand" Font-Bold="True"></asp:LinkButton>--> <!--<a href='<%# Eval("Title") %>' style="text-decoration: none; font-weight: bold" runat="server"><%# Eval("Title") %></a>--> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "ShowProductDetails.aspx?ARG="+(Eval("URLProduct") +"&Companyurl="+ Eval("URLCompany")).Replace("./?", "http://www.sme.ir/&") %>' Text='<%# Eval("Title") %>' Font-Bold="True"></asp:HyperLink> </td> </tr> <tr> <td> <label runat="server" visible="false"><%# Eval("Price")%></label> </td> </tr> <tr><td> <!-- <a href='<%# Eval("URLCompany") %>' runat=