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

  • Home
  • SEARCH
  • 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 1110403
In Process

The Archive Base Latest Questions

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

I am trying to set the top gridview’s column’s width to the body’s column

  • 0

I am trying to set the top gridview’s column’s width to the body’s column width and then the left columns height to the body’s coloumns height. Here is my code:

<form id="form1" runat="server">
<div>
    <asp:Table ID="Table1" runat="server">
        <asp:TableRow>
            <asp:TableCell>
            </asp:TableCell><asp:TableCell>
                <asp:GridView ID="GridView2" runat="server" ShowHeader="false">
                </asp:GridView>
            </asp:TableCell></asp:TableRow>
        <asp:TableRow>
            <asp:TableCell>
                <asp:GridView ID="GridView3" runat="server" ShowHeader="false">
                </asp:GridView>
            </asp:TableCell><asp:TableCell>
                <asp:GridView ID="GridView4" runat="server" ShowHeader="false">
                </asp:GridView>
            </asp:TableCell></asp:TableRow>
    </asp:Table>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</form>

Here is the code behinde:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt1 = new DataTable();
                DataTable dt2 = new DataTable();
                DataTable dt3 = new DataTable();

                DataRow row;

                dt1.Columns.Add(new DataColumn("Description", Type.GetType("System.String")));
                dt1.Columns.Add(new DataColumn("ROXORZZOZO!!", Type.GetType("System.String")));
                dt1.Columns.Add(new DataColumn("MY", Type.GetType("System.String")));
                row = dt1.NewRow();
                row["Description"] = "WOOOO";
                row["ROXORZZOZO!!"] = "EOOOOOOOOOOOOOOOOOOOOO!";
                row["MY"] = "My time to shine!";
                dt1.Rows.Add(row);
                row = dt1.NewRow();
                row["Description"] = "MO!";
                row["ROXORZZOZO!!"] = "EOOOO!";
                row["MY"] = "My time to dine!";
                dt1.Rows.Add(row);
                row = dt1.NewRow();
                row["Description"] = "WOOOO";
                row["ROXORZZOZO!!"] = "EOOOOOOOOOOOOOOOOOOOOO!Hey Guys,Today(Thursday) I need to leave early at three to take care of some personal business.  Also, next Wednesday I’m going to be out of the office all day, taking a welding certification test.  I’ll also send out an OOO form.";
                row["MY"] = "My time to be fine!";
                dt1.Rows.Add(row);

                dt2.Columns.Add(new DataColumn("Description", Type.GetType("System.String")));
                dt2.Columns.Add(new DataColumn("ROXORZZOZO!!", Type.GetType("System.String")));
                dt2.Columns.Add(new DataColumn("MY", Type.GetType("System.String")));
                row = dt2.NewRow();
                row["Description"] = "Description";
                row["ROXORZZOZO!!"] = "ROXORZZOZO!!";
                row["MY"] = "MY";
                dt2.Rows.Add(row);

                dt3.Columns.Add(new DataColumn("Row Numbers", Type.GetType("System.String")));
                row = dt3.NewRow();
                row["Row Numbers"] = "1";
                dt3.Rows.Add(row);
                row = dt3.NewRow();
                row["Row Numbers"] = "2";
                dt3.Rows.Add(row);
                row = dt3.NewRow();
                row["Row Numbers"] = "3";
                dt3.Rows.Add(row);
                GridView3.DataSource = new DataView(dt3);
                GridView2.DataSource = new DataView(dt2);
                GridView4.DataSource = new DataView(dt1);
                GridView2.DataBind();
                GridView3.DataBind();
                GridView4.DataBind();
                SynchGridviews(GridView2, GridView3, GridView4);
            }
        }

    protected void SynchGridviews(GridView top, GridView left, GridView body)
        {
            if (top.Width.Value > body.Width.Value)
            {
                body.Width = top.Width;
            }
            else
            {
                top.Width = body.Width;
            }

            if (left.Height.Value > body.Height.Value)
            {
                body.Height = left.Height;
            }
            else
            {
                left.Height = body.Height;
            }
            GridView2.DataBind();
            GridView3.DataBind();
            GridView4.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SynchGridviews(GridView2, GridView3, GridView4);
        }
  • 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-17T02:23:27+00:00Added an answer on May 17, 2026 at 2:23 am

    If your table is snug against its surrounding divs, then you will be unable to re-size your columns/rows, so create a giant div around your table and you will be able to re-size it.

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

Sidebar

Related Questions

I'm trying to set the width of table column to a minimum value. The
I am trying to set the icon that appears in the top-left corner of
I am trying to set Padding Top to Specified View from another Layout Height
I have one image on top of another.In code I am trying to set
Trying to set RowHeight like this(in code): dgvTruckAvail.RowTemplate.Height = 48; Doesnt' work. I also
I am trying to set up a hbase cluster which is running on top
Trying to set it so if a certain condition is met then one of
im trying to set the height of two divs on my page, because my
I am trying to add a new column in a GridView but it doesn't
I am trying to set a nested div on the top right of its

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.