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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:59:12+00:00 2026-05-13T23:59:12+00:00

protected void GridView1_DataBound(object sender, EventArgs e) { GridView1.Columns[0].ItemStyle.Width = 400; <asp:GridView ID=GridView1 runat=server DataSourceID=ObjectDataSource1

  • 0
protected void GridView1_DataBound(object sender, EventArgs e)
{
    GridView1.Columns[0].ItemStyle.Width = 400;

  <asp:GridView ID="GridView1" runat="server" 
        DataSourceID="ObjectDataSource1"

ObjectDataSource1 returns data table , but I can’t find any width property there , so I guess there is GridView side option but even on data bound there is like no columns …

protected void GridView1_DataBound(object sender, EventArgs e)
{
    if (GridView1.Columns.Count!=0)
        GridView1.Columns[0].ItemStyle.Width = 800;

Question : how to set width for column in my grid

asp :

  <asp:Panel id="Panel1" runat="server" ScrollBars="Auto" style="width:990px; border-style: outset; border-width: 4px;">
  <asp:Label ID="ERROR" runat="server"></asp:Label>
  <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
      SelectMethod="GetReport" TypeName="SQF.SQF">
      <SelectParameters>
          <asp:Parameter DefaultValue="2010" Name="Param1" Type="String" />
          <asp:Parameter DefaultValue="1" Name="Param2" Type="Int32" />
          <asp:Parameter DefaultValue="0" Name="Group" Type="Int32" />
          <asp:Parameter DefaultValue="0" Name="DayOfMonth" Type="Int32" />
      </SelectParameters>
  </asp:ObjectDataSource>

  <asp:GridView ID="GridView1" runat="server" 
        DataSourceID="ObjectDataSource1" Width="591px" 
        CellPadding="4" ForeColor="#333333"
        HorizontalAlign="Center" AllowPaging="True"  PageSize="6" 
          onrowdatabound="GridView1_RowDataBound">
        <PagerSettings FirstPageText="&#1055;&#1077;&#1088;&#1074;&#1072;&#1103;" 
            LastPageText="&#1055;&#1086;&#1089;&#1083;&#1077;&#1076;&#1085;&#1103;&#1103;" 
            PageButtonCount="15" position="Bottom" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle CssClass="pagination" HorizontalAlign="Center" 
                VerticalAlign="Middle" 
            Font-Size="14pt" Wrap="True" BackColor="#284775" ForeColor="White"/>
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Center" 
            VerticalAlign="Middle" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" 
            VerticalAlign="Middle" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" 
            HorizontalAlign="Center" VerticalAlign="Middle" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" 
            Font-Names="Arial" />
        <EditRowStyle BackColor="#999999" HorizontalAlign="Center" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" 
            HorizontalAlign="Center" />
  </asp:GridView>

css :

.wide  {
border:3px solid black;
width:400px;
}
css-content.css (строка 778)
from tr
element.style {
color:#333333;
}
from table#ctl00_ContentPlaceHolder1_GridView1
element.style {
border-collapse:collapse;
color:#333333;
}
from div#ctl00_ContentPlaceHolder1_Panel1
element.style {
border-style:outset;
}
from body
body {
color:#666666;
font-family:Verdana,Arial,Helvetica,sans-serif;
font-size:0.7em;
line-height:1.4em;
}
  • 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-13T23:59:13+00:00Added an answer on May 13, 2026 at 11:59 pm

    If you always want the same width, I’d do it with CSS. You can do it like this:

    GridView1.Columns[0].ItemCssClass = "wide";
    

    And in CSS:

    .wide { width: 400px; }
    

    If you set the width on the item style, that css id repeated in the html for every cell in that column, this way at least it’s less markup.

    If you’re using auto generated columns then the actual columns collection is empty and you’ll need to hook up to the RowDataBound event like this:

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
      e.Row.Cells[0].CssClass = "wide";
    }
    

    In your GridView markup add OnRowDataBound="GridView1_RowDataBound"

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

Sidebar

Ask A Question

Stats

  • Questions 383k
  • Answers 383k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think JavaScript is the wrong approach. (You start off… May 14, 2026 at 10:48 pm
  • Editorial Team
    Editorial Team added an answer Try the word-wrap property: word-wrap: break-word; -ms-word-wrap: break-word; May 14, 2026 at 10:48 pm
  • Editorial Team
    Editorial Team added an answer Try: = from g in lstGroupings.OfType<GroupingNNA>() this will skip any… May 14, 2026 at 10:48 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.