Link to home
Create AccountLog in
Avatar of Lagi
Lagi

asked on

Datagrid column width manipulation

I have a datagrid which is connected to a dataview which is connected to a dataset.
I want to know how can I set EACH column width differently, something like : datagrid.column[0].width = 100, datagrid.column[1].width = 130, etc.
Avatar of mpest
mpest
Flag of United States of America image

Do it from your aspx page, not the aspx.cs page

<asp:TemplateColumn HeaderText="Cost">
     <ItemTemplate>
          <asp:Label id="lblCost" runat="server" text='<%# Convert.ToString(DataBinder.Eval(Container.DataItem,"Cost")) %>' Width="75" />
     </ItemTemplate>
<asp:TemplateColumn>

Will set it to 75
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Lagi
Lagi

ASKER

The grid in within windows application not browser.
did you try
DG.Columns[0].HeaderStyle.Width = 100