Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > DataGrid Column Width

Reply
Thread Tools

DataGrid Column Width

 
 
frank
Guest
Posts: n/a
 
      07-21-2003
How do I set the column width of a column in a DataGrid programatically (in
ASP.NET web pages)?

I understand I may have to use DataGridTableStyle, but I can't get this to
work with web pages.

Any help would be appreciated.


 
Reply With Quote
 
 
 
 
Saravana
Guest
Posts: n/a
 
      07-21-2003
you can programmatically change width of the column like this,

datagrid1.Columns(0).ItemStyle.Width.Pixel(150)

or

datagrid1.Columns(0).ItemStyle.Width = new Unit(150,UnitType.Pixel)


--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.


"frank" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> How do I set the column width of a column in a DataGrid programatically

(in
> ASP.NET web pages)?
>
> I understand I may have to use DataGridTableStyle, but I can't get this to
> work with web pages.
>
> Any help would be appreciated.
>
>



 
Reply With Quote
 
 
 
 
Ignacio Machin
Guest
Posts: n/a
 
      07-21-2003
Hi Frank,

You can use DataGrid.Columns[X].ItemStyle.Width , here goes an example:
this.locationgrid.Columns[2].Visible = this.locationgrid.Columns[3].Visible
= false;

this.locationgrid.Columns[1].ItemStyle.Width= 460;



Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"frank" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> How do I set the column width of a column in a DataGrid programatically

(in
> ASP.NET web pages)?
>
> I understand I may have to use DataGridTableStyle, but I can't get this to
> work with web pages.
>
> Any help would be appreciated.
>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-21-2003
Just remember, that whatever you do in the code, meaning whatever HTML it
produces, a browser on client's machine will consider it as a recomendation
rather than an instruction.

Since you can hardly be sure what width the browser will assign to your
columns, it's not a good idea to rely on exact column width in your design.

Eliyahu

"Saravana" <(E-Mail Removed)> wrote in message
news:e$(E-Mail Removed)...
> you can programmatically change width of the column like this,
>
> datagrid1.Columns(0).ItemStyle.Width.Pixel(150)
>
> or
>
> datagrid1.Columns(0).ItemStyle.Width = new Unit(150,UnitType.Pixel)
>
>
> --
> Saravana
> Microsoft India Community Star,
> MCAD,SE,SD,DBA.
>
>
> "frank" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > How do I set the column width of a column in a DataGrid programatically

> (in
> > ASP.NET web pages)?
> >
> > I understand I may have to use DataGridTableStyle, but I can't get this

to
> > work with web pages.
> >
> > Any help would be appreciated.
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
picture width decides table column width David Basford HTML 3 09-30-2007 10:49 PM
fixed-width column and variable-width columns mixed ssk HTML 5 10-30-2006 07:50 AM
setting Column width of Template Column in Datagrid.. Charleees ASP .Net 2 06-20-2006 12:52 PM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM
DG Column Width vs Table Column Width Carl Howarth ASP .Net Datagrid Control 1 10-24-2004 08:48 AM



Advertisments