473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Set Width in DataGrid columns

I have a dataGrid control in an ascx module. The code is this:

gridUsers.DataSource = users.GetUsers();
gridUsers.DataBind();

As you can see, the GetUsers() method returns a DataSet object.

What I want is modify the widht of the columns. I have to do it in code
(because it's linked in runtime) but I don't know how to do it.

Thank you.
Nov 18 '05 #1
3 1289
The width of the columns is set in the ascx file and hasn't got anything to
do with DataBinding. You set the width by using the syntax
ItemStyle-Width="width" and HeaderStyle-Width="width" in your BoundColumn
or TemplateColumn

"Alberto" <al*****@nospam.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
I have a dataGrid control in an ascx module. The code is this:

gridUsers.DataSource = users.GetUsers();
gridUsers.DataBind();

As you can see, the GetUsers() method returns a DataSet object.

What I want is modify the widht of the columns. I have to do it in code
(because it's linked in runtime) but I don't know how to do it.

Thank you.

Nov 18 '05 #2
I tried with this:
gridUsers.Columns[0].ItemStyle.Width = 1000;
and with this:
gridUsers.Columns[0].Heather.Width = 1000;

But none of them works.

"Janaka" <ja****@magicalia.com> escribió en el mensaje
news:uH**************@TK2MSFTNGP12.phx.gbl...
The width of the columns is set in the ascx file and hasn't got anything to do with DataBinding. You set the width by using the syntax
ItemStyle-Width="width" and HeaderStyle-Width="width" in your BoundColumn
or TemplateColumn

"Alberto" <al*****@nospam.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
I have a dataGrid control in an ascx module. The code is this:

gridUsers.DataSource = users.GetUsers();
gridUsers.DataBind();

As you can see, the GetUsers() method returns a DataSet object.

What I want is modify the widht of the columns. I have to do it in code
(because it's linked in runtime) but I don't know how to do it.

Thank you.


Nov 18 '05 #3
Try doing it in the html portion of the ascx file
i.e.

<BoundColumn id="Heather" DataField="foo" ItemStyle-Width="1000" />

"Alberto" <al*****@nospam.com> wrote in message
news:Oe*************@tk2msftngp13.phx.gbl...
I tried with this:
gridUsers.Columns[0].ItemStyle.Width = 1000;
and with this:
gridUsers.Columns[0].Heather.Width = 1000;

But none of them works.

"Janaka" <ja****@magicalia.com> escribió en el mensaje
news:uH**************@TK2MSFTNGP12.phx.gbl...
The width of the columns is set in the ascx file and hasn't got anything

to
do with DataBinding. You set the width by using the syntax
ItemStyle-Width="width" and HeaderStyle-Width="width" in your BoundColumn or TemplateColumn

"Alberto" <al*****@nospam.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
I have a dataGrid control in an ascx module. The code is this:

gridUsers.DataSource = users.GetUsers();
gridUsers.DataBind();

As you can see, the GetUsers() method returns a DataSet object.

What I want is modify the widht of the columns. I have to do it in code (because it's linked in runtime) but I don't know how to do it.

Thank you.



Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Prateek | last post by:
Hi, How can I change the width of a column in datagrid control? TIA Prateek
9
by: web1110 | last post by:
Hi y'all, I have resized the columns in a DataGrid and I want to set the width of the DataGrid to fit the columns. Just summing the column widths is too short due to the grid and gray row...
24
by: Mike L | last post by:
This is for a Win form, in C# 2005. I want to load a datagrid, make some columns width 0, and then clean out the record I added. I get the error message, ""Index was out of range. Must be...
3
by: Andre | last post by:
Hi, Did someone know why this code does'nt work (The TableCell Width). The cell don't have 600 and 150 like writed in width="600" and width="150". <asp:datagrid id="DataGrid1" ...
5
by: VB Programmer | last post by:
I have a simple datagrid on a webform. (I'm using VB.NET.) In the page load I get some data, set the .DataSource property of the dg, then do a .DataBind. The columns are automatically created. ...
1
by: VB Programmer | last post by:
I have a datagrid which is bound to a datatable that I create on the fly. How do I set the width of each column via code? Ex: Column 1 is always 100, Column 2 is always 250, etc... Thanks!
0
by: Reza Nabi | last post by:
Dear All: Banckgroud: I have a datagrid which lives inside a repeater. Which is working fine. What i need is to dyanamically set the column width of the grid (which lieves inside the repeater)....
5
by: John M | last post by:
Hello, In Visual Studio .NET 2003, How can I change the columns' width (at design or runtime) of datagrid ? Thanks :)
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
3
by: remya1000 | last post by:
I’m using Vb.net application program. I created a datagrid having text field and checkbox fields. Everything is displaying correctly. I have 9 Columns and each columns are equally separated. In...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.