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 7765025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:04:24+00:00 2026-06-01T15:04:24+00:00

I have two grid, one with auto-generated fields and the other not. how can

  • 0

I have two grid, one with auto-generated fields and the other not. how can i export two of the grid (which is actually together to one?) The following code illustrate how i bind two grid together using methods and a early image of the grid.

my code:

protected void BindHistoryReport()
{
    ArrayList listofavgrating = new ArrayList();
    ArrayList listofdouble = new ArrayList();
    ArrayList listofquestion = dbmanager.GetAllQuestion();
    ArrayList listofstaff = dbmanager.GetAllStaffDetails();
    DataTable dt = new DataTable();
    DataRow dr = null;
    int count = 0;

    foreach (staffinfo stf in listofstaff)
    {
        ArrayList listofhistorydates = dbmanager.GetTotalHistoryDates(stf.Uid);
        if (count==0)
        {
            dt.Columns.Add(new DataColumn("UserID", typeof(string)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));
            dt.Columns.Add(new DataColumn("Section", typeof(string)));
            dt.Columns.Add(new DataColumn("Function", typeof(string)));
            count++;
        }

        if (listofhistorydates.Count != 0 && listofquestion.Count != 0 && count > 0)
        {
            dr = dt.NewRow();
            dr["UserID"] = stf.Uid;
            dr["Name"] = stf.Name;
            dr["Section"] = stf.Section;
            dr["Function"] = stf.Function;
            dt.Rows.Add(dr);
        }
    }
    if (count > 0)
    {
        ViewState["HistoryGrid"] = dt;
        Session["ListofQuestion"] = listofquestion;
        ViewAllHistory.DataSource = dt;
        ViewAllHistory.DataBind();
        BindInsideGradeGrid();
        LegendMessage();
        MultiView1.ActiveViewIndex = 0;
    }
    else
    {
        Response.Redirect("default.aspx");
    }
}

protected void BindInsideGradeGrid()
{
    ArrayList listofquestion = (ArrayList)Session["ListofQuestion"];
    DataTable maintable = (DataTable)ViewState["HistoryGrid"];
    int indexgrid = 0;
    foreach (DataRow row in maintable.Rows)
    {
        DataTable dt2 = new DataTable();
        DataRow dr2 = null;
        string userid = row["UserID"].ToString();
        ArrayList listofhistorydates = dbmanager.GetTotalHistoryDates(userid);

        for (int i = 0; i < listofhistorydates.Count; i++)
        {
            DateTime toshortdate=((DateTime)listofhistorydates[i]);
            dt2.Columns.Add(new DataColumn(toshortdate.ToShortDateString(), typeof(double)));
        }

        int index = 0;
        double result = 0.0;
        dr2 = dt2.NewRow();
        foreach (DateTime date in listofhistorydates)
        {
            foreach (Question qn in listofquestion)
            {
                result += dbmanager.GetAvgRating(userid, date, qn.QuestionID);
            }
            result = Math.Round((result / listofquestion.Count), 1);
            DateTime toshortdate = ((DateTime)listofhistorydates[index]);
            dr2[toshortdate.ToShortDateString()] = result;
            index++;
            result = 0.0;
        }
        dt2.Rows.Add(dr2);
        GridView gv = (GridView)ViewAllHistory.Rows[indexgrid].FindControl("GridView1");
        //gv.ControlStyle.Width = 500;
        gv.DataSource = dt2;
        gv.DataBind();
        indexgrid++;
    }
}

design:

<asp:GridView ID="ViewAllHistory" runat="server" BorderWidth="1px" 
                            CellPadding="1" CellSpacing="1" BackColor="Black" 
                            AutoGenerateColumns="False" PageSize="1">
                            <RowStyle BackColor="White"/>
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="ViewBtn" runat="server" onclick="ViewBtn_Click">View</asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="UserID" HeaderText="User ID" />
                                <asp:BoundField DataField="Name" HeaderText="Name" >
                                </asp:BoundField>
                                <asp:BoundField DataField="Section" HeaderText="Section" />
                                <asp:BoundField DataField="Function" HeaderText="Function" />
                                <asp:TemplateField HeaderText="Grade">
                                    <ItemTemplate>
                                        <asp:Panel ID="ScrollPanel" style="width:760px" runat="server" ScrollBars="Horizontal"> 
                                            <asp:GridView ID="GridView1" style="position:static" runat="server" BorderWidth="1px" BackColor="Black">
                                            <FooterStyle BackColor="#CCCCCC" />
                                            <RowStyle BackColor="White" Wrap="true"/>
                                            <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                                            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                                            </asp:GridView>
                                        </asp:Panel>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <FooterStyle BackColor="#CCCCCC" />
                            <PagerSettings Position="TopAndBottom" />
                            <PagerStyle HorizontalAlign="Center" BackColor="White" />
                            <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                        </asp:GridView>

image: enter image description here

  • 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-01T15:04:25+00:00Added an answer on June 1, 2026 at 3:04 pm

    This link shows a possible similar problem to yours. How To exporting to Excel parent and nested GridView data?

    You would need to iterate the rows of the grid, and see if any child grids exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two DropDownListBoxes one is called ddlDay and the other is ddlMonth. As
I have Two Labels such as FixedTotal and TotalPercent, One GridView which has One
I have two screens the one which list the records in a listview ListView
I have two forms, one to edit room details and the other to edit
I have a grid view that has two simple columns, a report number and
Hi I have a grid of around 30 cells each with two images, a
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two application that need to talk to each other. App1 needs to
I have two classes generated by LINQ2SQL both from the same table so they
I have two queries, as following: SELECT SQL_CALC_FOUND_ROWS Id, Name FROM my_table WHERE Name

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.