I have created a datagrid by codebehind and want to adjust the column width at runtime. I did this:
I got an error that : ... Index is out of range. I then compared data in the grid and data in the datatable to check if there is any data in the grid. I could not find any. I checked like this :
The result was : 0 vs 6. However, the code runs fine. I see all 6 columns with data in the grid. What is be wrong here. How can I access data bound in the datagrid and adjust the width size? Please help. Thanks for helping.
Code:
mgrid.itemssource=dt.defaultview
mgrid.Columns(0).Width=200
Code:
mgrid.itemssource=dt.defaultview.
Msgbox( mgrid.Columns.count & vs & dt.Columns.Count)