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
1180
Grid and combo with datatable
posted

Hi guys.
I wanted to have a winGrid with only two columns. The first of these columns would be normal and then the second would be a combo.
I fill my WinGrid with a data table as follows:


        DtUnits Dim As New DataTable ("dtUnits")
        dtUnits. Columns.Add ("Data")
        dtUnits. Columns.Add ("Unit")
             While dateB <dateF
                 Dim row As DataRow = dtUnits.NewRow ()
                 row (0) = dateB 'Date mm / dd / yyyy
                 row (1) = "I want COMBO HERE BASED ON another DataTable"
                 dtUnits.Rows.Add (row)
                 dateB = DateAdd (DateInterval.Day, 1, CDate (dateB))
             end While
Me.GRID.DataSource = dtUnits

The combo would serve to enter the unit available on that date, then the combos would be different. I would have units available at a date and unavailable elsewhere.

I inserted the code "e.Layout.Bands (0). Columns (" Unit "). ColumnStyle.DropDownList = Style" at the event InitializeLayout

Parents Reply
  • 1180
    posted in reply to Mike Saltzman

    I really need help. I can not solve my problem.
    The screen that you see below. I put the date of checkin and checkout date and type of unit that I seek.
    By clicking the button I need to show in grid units available for the selected type the date in question.



    So what i am doing in the button click event:
    I create a DataTable with the columns Date and Unit, then in a while with the check-in and check-out date I added the rows.

    what better way to do that this way of working ?

    This is the code I use to fill the grid

    Dim dt As New DataTable("dt")
    dtUnidadesReserva.Columns.Add("Date")
    dtUnidadesReserva.Columns.Add("Unit")
    While CDate(DCheckin) < (DCheckout)
            Dim row As DataRow = dtUnidadesReserva.NewRow()
            row(0) =
    DCheckin
            row(1) = HERE NEED A COMBO
           
    dt .Rows.Add(row)
           
    DCheckin= DateAdd(DateInterval.Day, 1, CDate(DCheckin))
    End While
    Me.appGridUnidadesReserva.DataSource =
    dt

    This is the code I use to check the units of a certain kind available at a certain date.

    Dim dt As New DataTable("dt ")
     dtQuartoVago.Columns.Add("idUnit")
    dtQuartoVago.Columns.Add("Unit")
    ###
    sub to open the connection to the database
    sql = "SQL instruction"
    RS.Open(sql, BDMain, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly)
    While Not RS.EOF
            Dim row As DataRow = dt.NewRow()
            row(0) = RS("
    idUnit").Value
            row(1) = RS("
    Unit").Value
            dt.Rows.Add(row)
            'RS.MoveNext()

    End While
    RS.Close()
    ###
    sub to close connection to the database


Children