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
535
Run time columns not showing
posted

Hello everyone,

I am having problems with a webdatagrid, I have created 2 bounddatafield objects which I have added to the webdatagrid.columns collection.

After that, I assigned a dataset to function as a datasource (I also turned off autogeneratecolumns)

I then called the webdatagrid.databind function to finalise the proces. 

The problem is that the columns aren't being rendered on screen. When debugging I can see that the webdatagrid has 2 columns.

The purpose of this project is that I want users to be able to set the datasource through a combobox, so I want to set the datasource of the grid dynamically but I only want to show 2 or 3 column of the datatable.

Any help would be appreciated

 

Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender

        Dim adapt As New DSMailboxTableAdapters.t_InboxTableAdapter
        adapt.FillByMechanicID(_ds.t_Inbox, _mechanicID)

        WebDataGrid1.AutoGenerateColumns = False

        Dim c_Message As New Infragistics.Web.UI.GridControls.BoundDataField
        c_Message.DataFieldName = "Message"
        c_Message.Key = "Message"

        Dim c_Status As New Infragistics.Web.UI.GridControls.BoundDataField
        c_Status.DataFieldName = "MessageStatus"
        c_Status.Key = "MessageStatus"

        WebDataGrid1.Columns.Add(c_Message)
        WebDataGrid1.Columns.Add(c_Status)

        WebDataGrid1.DataSource = _ds.t_Inbox

        WebDataGrid1.DataBind()

    End Sub