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
15
Why my column in webdatagrid didn't hide after databind method?
posted

I confirmed the app run this dglist_initializeRow event before bind the data into the datagrid.

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

e.Row.Items.FindItemByKey("SNIndex").Column.Hidden = True
e.Row.Items.FindItemByKey("Format").Column.Hidden = True
e.Row.Items.FindItemByKey("FormatRef").Column.Hidden = True
e.Row.Items.FindItemByKey("SPONoRef").Column.Hidden = True

End Sub

the data extract from database and convert into datatable before bind to datagrid

dgLis.t.DataSource = dsSNFormat.Tables(0)

dgList.DataBind()

after binding the data, I call this function to hide the column that I want, but unfortunately, only the header and width take effect from this function. My column still not hiding as I expect.

Public Sub showhidecolumn()

For a As Integer = 0 To dgList.Rows.Count - 1
dgList.Rows(a).Items(0).Column.Hidden = True
dgList.Rows(a).Items(0).Column.Width = 0
dgList.Rows(a).Items(0).Column.Header.Text = ""
dgList.Rows(a).Items(1).Column.Hidden = True
dgList.Rows(a).Items(1).Column.Width = 0
dgList.Rows(a).Items(1).Column.Header.Text = ""
dgList.Rows(a).Items(5).Column.Hidden = True
dgList.Rows(a).Items(5).Column.Width = 0
dgList.Rows(a).Items(5).Column.Header.Text = ""
dgList.Rows(a).Items(11).Column.Hidden = True
dgList.Rows(a).Items(11).Column.Width = 0
dgList.Rows(a).Items(11).Column.Header.Text = ""
Next
End Sub

Any suggestion? by the way, my column type is BoundDataField, is it got a special trick to hide that column's type? Please help I'm quite stuck right now.

Thanks in advance.