Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8443341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:06:42+00:00 2026-06-10T09:06:42+00:00

I am using Nested GridViews where each row in the gridview has child gridView.

  • 0

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.

This is my Aspx page

         <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">
                    <%--<AlternatingRowStyle BackColor="ButtonFace" />--%>
                    <Columns>
                        <asp:TemplateField ItemStyle-Width="5%">
                            <ItemTemplate>
                                <asp:HiddenField ID="hdnClaimNo" runat="server" Value='<%# Eval("ClaimNo") %>' />
                                <asp:Image runat="server" ID="img1" ImageUrl="../images/Collapse_plus.png" />
                            </ItemTemplate>
                            <ItemStyle Width="5%"></ItemStyle>
                        </asp:TemplateField>
              <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" >
                                    <%--SkinID="GridView"--%>
                                    <Columns>
                                        <asp:TemplateField FooterStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
                                            <HeaderTemplate>
                                                Sub Claim No
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="lblSubClaimNoValue" Width="" runat="server" Text='<%#Eval("SubClaimNo")%>'></asp:Label>
                                            </ItemTemplate>
                                            <FooterStyle HorizontalAlign="Left" />
                                        </asp:TemplateField>
           <asp:Button ID="btnSubrogation" CssClass="groovybutton" runat="server" CommandName="Subrogation"
                                                    Text="Subrogation" CommandArgument='<%# Eval("ClaimNo") + "~" + Eval("SubClaimNo")%>' />
                                                <asp:Button ID="btnSalvage" CssClass="groovybutton" runat="server" CommandName="Salvage"
                                                    Text="Salvage" CommandArgument='<%# Eval("ClaimNo") + "~" + Eval("SubClaimNo")%>' />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <AlternatingRowStyle CssClass="" />
                                    <RowStyle CssClass="ob_gBody" />
                                    <HeaderStyle CssClass="gridHeader" />
                                </asp:GridView>
                                <asp:Literal runat="server" ID="Literal2" Text="</td></tr>" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>

This is My aspx.cs file

 protected void grdSubClaimOuter_RowDataBound(object sender, GridViewRowEventArgs e)
{

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        if (e.Row.Cells[1].Text.ToString() != "&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 > 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]);
            }

        }

    }
}

if anyone knows it,please help me solve this problem.thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:06:43+00:00Added an answer on June 10, 2026 at 9:06 am

    First get a reference to the child GridView, then use FindControl to get the Button inside it:

    foreach (GridViewRow row in grdSubClaimOuter.Rows) 
    {
    if (row.RowType == DataControlRowType.DataRow) 
    {
        GridView gvChild = (GridView) row.FindControl("grdSubClaim");
        // Then do the same method for Button control column 
        if (gvChild != null)
        {
            foreach (GridViewRow row in gvChild .Rows) 
            {
                if (row.RowType == DataControlRowType.DataRow) 
                {
                    Button btn = (Button ) row.FindControl("buttonID");
                    if (btn != null )
                    {
                        // do your work
                    }
                }
            }
        }
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Nested GridViews where each row in the gridview has child gridView.
i am using nested gridview, on RowDatabound Event i am binding childgridview based on
I have a Repeater nested inside of a GridView . On the RowDataBound event
I am using a accordion control which has nested gridviews within the content section
I'm trying to get an average of sums using nested aggregate functions and grouping.
I am currently asked to compare certain images with each other (using nested for
I'm having a problem using nested partials with dynamic form builder code (from the
I'm building an app using Brunch and Backbone.js that is to include nested menus.
I am using nested master pages, which may or may not cause the problem
I have a problem with the normal way rails operates when using nested forms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.