Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
50
Setting column width when binding empty table.
posted

I'm creating the webdatagrid by binding datatable with one row witch becomes header.

I have the DefaultColumnWidth set and it works for all columns.

What I want to do is set a different column width for different columns.

But the webdatagrid says it has no rows nor columns.

It begins like this:

WebTableControl.DataSource = table
WebTableControl.DataBind()

WebTableControl.DefaultColumnWidth = 150
TableControlBase.getViewState("table") = table

Than what I've tried to do is:

1:

WebTableControl.Rows(0).Items(7).Column.Width = 400

WebTableControl.Rows(0).Items(6).Column.Width = 100

2:


WebTableControl.Columns("column name").Width = 400
WebTableControl.Columns("column name 2").Width = 200

3:


For Each igrow As Infragistics.Web.UI.GridControls.GridRecord In WebTableControl.Columns

.....

Next

None of those seems to work.

After adding a row what does work is this:

Protected Sub ApplyFieldSettings_InitializeRow(sender As Object, e As Infragistics.Web.UI.GridControls.RowEventArgs) Handles WebTableControl.InitializeRow
.......

Dim IGRow As Infragistics.Web.UI.GridControls.GridRecord = e.Row

But not on a empty webdatagrid.

Any suggestions?

Parents
No Data
Reply
  • 50
    Verified Answer
    posted

    Found a solution maybe someone will need it.

    I've just added a row to the table (any row) binded table to webdatagrid, then removed the row and binded again.

    Thanks to that the initializerow event fired and the webdatagrid keept the columns width set in the event.

Children
No Data