<asp:TemplateField> <ItemTemplate> <asp:HyperLink ID="HyperLink1" Text='<%# Eval("RowName") %>' runat="server"></asp:HyperLink> </ItemTemplate> <ItemStyle BorderStyle="None" /> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:ImageButton ID="ImageButton1" CommandArgument='<%# Eval("1") %>' CommandName="ib1" Visible='<%# MyVisible(Eval("1").ToString()) %>' runat="server" ImageUrl="~/images/wchair.jpg" /> </ItemTemplate> <ItemStyle BorderStyle="None" /> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:ImageButton ID="ImageButton2" runat="server" CommandArgument='<%# Eval("2") %>' CommandName="ib2" Visible='<%# MyVisible(Eval("2").ToString()) %>' ImageUrl="~/images/wchair.jpg" /> </ItemTemplate> <ItemStyle BorderStyle="None" /> </asp:TemplateField>
protected void gvScreenLayout_RowCommand(object sender, GridViewCommandEventArgs e) { int ColumnIndex = Convert.ToInt32(e.CommandName);//this is fine HyperLink col = (HyperLink)gvScreenLayout.SelectedRow.FindControl("HyperLink1");//Error:Object is not set to an instance string columnindex = col.Text; }
protected void gvScreenLayout_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = Convert.ToInt32(e.CommandArgument); HyperLink hyperlink = (HyperLink)gvScreenLayout.Rows[rowIndex].FindControl("HyperLink1"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)