Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get button find control value in nested grid using c#
    text
    copied!<p>I am using Nested GridViews where each row in the gridview has child gridView. I am using RowDataBound Event of Parent GridView, to Binding Child GridView. My Problem is that, how to get Child GridView's Button findcontrol value in Parent gridViews RowDataBound Event.</p> <p>This is my Aspx page</p> <pre><code> &lt;asp:GridView ID="grdSubClaimOuter" SkinID="GridView" runat="server" Width="100%" AutoGenerateColumns="false" OnRowDataBound="grdSubClaimOuter_RowDataBound" OnRowCommand="grdSubClaimOuter_RowCommand" ShowFooter="false" AllowPaging="true" OnPageIndexChanging="grdSubClaimOuter_PageIndexChanging"&gt; &lt;%--&lt;AlternatingRowStyle BackColor="ButtonFace" /&gt;--%&gt; &lt;Columns&gt; &lt;asp:TemplateField ItemStyle-Width="5%"&gt; &lt;ItemTemplate&gt; &lt;asp:HiddenField ID="hdnClaimNo" runat="server" Value='&lt;%# Eval("ClaimNo") %&gt;' /&gt; &lt;asp:Image runat="server" ID="img1" ImageUrl="../images/Collapse_plus.png" /&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle Width="5%"&gt;&lt;/ItemStyle&gt; &lt;/asp:TemplateField&gt; &lt;asp:GridView ID="grdSubClaim" runat="server" SkinID="GridView" CellPadding="4" Width="100%" AutoGenerateColumns="false" ShowFooter="false" OnRowEditing="grdSubClaim_RowEditing" OnRowCommand="grdSubClaim_RowCommand" OnRowDeleting="grdSubClaim_RowDeleted" AllowPaging="false" &gt; &lt;%--SkinID="GridView"--%&gt; &lt;Columns&gt; &lt;asp:TemplateField FooterStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"&gt; &lt;HeaderTemplate&gt; Sub Claim No &lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="lblSubClaimNoValue" Width="" runat="server" Text='&lt;%#Eval("SubClaimNo")%&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;FooterStyle HorizontalAlign="Left" /&gt; &lt;/asp:TemplateField&gt; &lt;asp:Button ID="btnSubrogation" CssClass="groovybutton" runat="server" CommandName="Subrogation" Text="Subrogation" CommandArgument='&lt;%# Eval("ClaimNo") + "~" + Eval("SubClaimNo")%&gt;' /&gt; &lt;asp:Button ID="btnSalvage" CssClass="groovybutton" runat="server" CommandName="Salvage" Text="Salvage" CommandArgument='&lt;%# Eval("ClaimNo") + "~" + Eval("SubClaimNo")%&gt;' /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;AlternatingRowStyle CssClass="" /&gt; &lt;RowStyle CssClass="ob_gBody" /&gt; &lt;HeaderStyle CssClass="gridHeader" /&gt; &lt;/asp:GridView&gt; &lt;asp:Literal runat="server" ID="Literal2" Text="&lt;/td&gt;&lt;/tr&gt;" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>This is My aspx.cs file </p> <pre><code> protected void grdSubClaimOuter_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[1].Text.ToString() != "&amp;nbsp;") { Literal ltrChild = (Literal)e.Row.FindControl("ltrChild"); System.Web.UI.WebControls.Image img = (System.Web.UI.WebControls.Image)e.Row.Cells[0].FindControl("img1"); ltrChild.Text = ltrChild.Text.Replace("trChildGrid", "trChildGrid" + e.Row.RowIndex.ToString()); string strChildGrid = "trChildGrid" + e.Row.RowIndex.ToString(); e.Row.Cells[0].Attributes.Add("OnClick", "OpenTable('" + strChildGrid + "','" + img.ClientID + "')"); e.Row.Cells[0].RowSpan = 1; System.Web.UI.WebControls.GridView gvChild = (System.Web.UI.WebControls.GridView)e.Row.FindControl("grdSubClaim"); PolicyProcessor.DAL.Claim.ClaimSubClaim objDALClaimSubClaim = new PolicyProcessor.DAL.Claim.ClaimSubClaim(); PolicyProcessor.BOL.Claim.ClaimSubClaim objInfoClaimSubClaim = new PolicyProcessor.BOL.Claim.ClaimSubClaim(); HiddenField hdnClaimNo = (HiddenField)e.Row.FindControl("hdnClaimNo"); if (hdnClaimNo.Value != "") { objInfoClaimSubClaim.ClaimNo = hdnClaimNo.Value; } else { objInfoClaimSubClaim.ClaimNo = "0"; } DataSet dsChild; dsChild = objDALClaimSubClaim.ResultSet(objInfoClaimSubClaim, "SelectInnerGrid"); if (dsChild.Tables[0].Rows.Count &gt; 0) { Button btn = (Button)gvChild.FindControl("btnSalvage"); //btn is null how to get text value in btn btn.ForeColor = System.Drawing.Color.Red; gvChild.DataSource = dsChild; gvChild.DataBind(); } else { Helper.EmptyGrid(gvChild, dsChild.Tables[0]); } } } } </code></pre> <p>if anyone knows it,please help me solve this problem.thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload