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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:23:24+00:00 2026-05-18T02:23:24+00:00

This is very interesting.. I want to have multiple gridviews in a panel. and

  • 0

This is very interesting..

I want to have multiple gridviews in a panel. and the number of gridviews is not fixed..

So basically i think there should be no code in the .aspx page as i have to create the gridview in codebehind.

I have the code for 1 gridview in one panel.. where i define the grid view in the HTML page and populate it from the code behind.

Here is the code for that.. can any 1 please help me with the multiple gridviews…

this is on the .aspx page

       <asp:GridView ID="GridView1" runat="server"  AutoGenerateColumns="False" 
      AllowSorting="True" CellSpacing="2" onsorting="GridView1_Sorting"
                    Width="100%" ForeColor="White" GridLines="None" 
                      ondatabound="GridView1_DataBound1">

       <Columns>
                            <EditItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("PolicyID") %>'></asp:Label>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("PolicyID") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
      </Columns>
    </asp:GridView>

this is the code behind

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataTable dt = new DataTable();
            SqlConnection connection = new SqlConnection(Session["ConnectionStringSQL"].ToString()); 
            connection.Open();
            SqlCommand sqlCmd = new SqlCommand("SELECT Policies.PolicyID, FROM Policies", connection);
            SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);

            sqlDa.Fill(dt);
            connection.Close();

            if (dt.Rows.Count > 0)
            {
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    policyID.Add(dt.Rows[j]["PolicyID"].ToString());

                }
                taskTable.Columns.Add("PolicyID");


                if (policyID.Count != 0)
                {
                    for (int k = 0; k < policyID.Count; k++)
                    {
                        DataRow tableRow = taskTable.NewRow();

                        tableRow["PolicyID"] = policyID[k];

                        taskTable.Rows.Add(tableRow);
                    }

                    Session["TaskTable"] = taskTable;

                    GridView1.DataSource = Session["TaskTable"];
                    GridView1.DataBind();
                }
            }
        }
    }
  • 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-05-18T02:23:25+00:00Added an answer on May 18, 2026 at 2:23 am

    Not tested, but this kind of thing should do it:

    for (int i=0;i<5;i++) {
       GridView gv = new GridView();
       gv.DataSource = datasources[i];
       Page.Controls.Add(gv);
    }
    Page.DataBind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is very interesting to me... This image displays perfectly well in Safari, but
Have a look at this very simple example WPF program: <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
Let's make this very easy. What I want: @array = qw/one two one/; my
I'm sorry for this very newbish question, I'm not much given into web development.
I have a very nice idea for a kernel patch, and I want to
I want to have some to tool to explore our eventlogs. There are few
This very simple code gives me tons of errors: #include <iostream> #include <string> int
I've written this very simple function to replace a file extension using LINQ in
I find this very strange, must be something I'm doing wrong, but still... I'm
i am trying to compile this very simple piece of code class myList {

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.