nastoski
Technical User
- Oct 21, 2003
- 21
Dear All,
How can I change the width of columns in DataGrid. I'm using following code for DataGrid:
DataSet ds;
ds = managerService.ReturnDataSet("select * from
transactions");
tranDataGrid.DataSource = ds;
tranDataGrid.DataMember = "transactions";
transactionDataGrid.DataBind();
everything works fine (Datagrid is shown on the page) but when I add code to set the column width
transactionDataGrid.Columns[0].ItemStyle.Width = Unit.Pixel
(35);
error appear:
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Why is the collection of columns 0 and how can I change the width of the each column..
Thanks in advance!
Igor
How can I change the width of columns in DataGrid. I'm using following code for DataGrid:
DataSet ds;
ds = managerService.ReturnDataSet("select * from
transactions");
tranDataGrid.DataSource = ds;
tranDataGrid.DataMember = "transactions";
transactionDataGrid.DataBind();
everything works fine (Datagrid is shown on the page) but when I add code to set the column width
transactionDataGrid.Columns[0].ItemStyle.Width = Unit.Pixel
(35);
error appear:
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Why is the collection of columns 0 and how can I change the width of the each column..
Thanks in advance!
Igor