Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Set Width in DataGrid columns

Reply
Thread Tools

Set Width in DataGrid columns

 
 
Alberto
Guest
Posts: n/a
 
      02-04-2004
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.


 
Reply With Quote
 
 
 
 
Janaka
Guest
Posts: n/a
 
      02-04-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
 
 
 
Alberto
Guest
Posts: n/a
 
      02-04-2004
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" <(E-Mail Removed)> escribió en el mensaje
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.
> >
> >

>
>



 
Reply With Quote
 
Janaka
Guest
Posts: n/a
 
      02-04-2004
Try doing it in the html portion of the ascx file
i.e.

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

"Alberto" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> escribió en el mensaje
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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.
> > >
> > >

> >
> >

>
>



 
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
fixed-width column and variable-width columns mixed ssk HTML 5 10-30-2006 07:50 AM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM
How to set the width of columns of datagrid in edit mode. Vincent ASP .Net 1 08-17-2005 03:32 PM
I want to know how to set the width of columns in edit mode. Vincent ASP .Net 1 08-17-2005 04:08 AM
Table width and columns width kris HTML 11 11-18-2003 06:49 AM



Advertisments