I have an VB.Net ASP page that I have a datagrid on it with 5 columns and a few rows of data. The page will show the data and grid just fine. I need to now apply alignment to the datagrid columns.
dgLast5Bills.DataSource = dtBill
dgLast5Bills.DataBind()
dgLast5Bills.Columns(0).ItemStyle.HorizontalAlign = HorizontalAlign.Center
The code above will error out when it hits the line for the alignment. What am I doing wrong?
Thanks
Your
dgLast5Bills.Columns(0).ItemStyle.HorizontalAlign = HorizontalAlign.Centercode give youIndex was out of rangeerror because in youraspxpage you have not define any column, so at compile time there is no0index.You should try this.
For more reading look at it. DataGrid.ItemDataBound Event