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
275
Dynamically add row(s) consisting of 2 ultradropdown columns to an ultrawingrid based on a datasource
posted

I have an ultragrid populated by a blank "department" class: Dim AffDeptList As New BindingList(Of PTWAffDeptHeads)

This grid has 2 dropdowns, 1st one for departments and 2nd for people. (their datasources are populated by a stored procedure)

I can add rows (new dept and people) to the grid ok. I use the AddNew box to add new rows to the grid (and make my selections for the 2 dropdowns) and then save. the row data is successfully saved to the database.

But I need to have the grid populated from a datasource. So that the grid will list all the rows that were selected/saved. each row has a dropdown of a selected dept and a selected person that should show the selected value.

Here's how I'm loading my grid, and 2 dropdowns.

Dim PTWId As Guid
            'Fill Grid
            GridAffDepts.DataSource = AffDeptList

            'Fill Dept DropDown
            Dim ds As System.Data.DataSet
            ds = DataAccess.LoadDepts(formId)

            ddlDept_AffDeptList.SetDataBinding(ds, Nothing, True)
            ddlDept_AffDeptList.ValueMember = "DeptId"
            ddlDept_AffDeptList.DisplayMember = "DeptName"

            cboDept_AffDeptList.ValueMember = "DeptId"
            cboDept_AffDeptList.DisplayMember = "DeptName"
            cboDept_AffDeptList.DataSource = ds.Tables(0)

            'Fill POB DropDown
            ds = DataAccess.SelectPerson(formId)
            ddlPOB_AffDeptList.SetDataBinding(ds, Nothing, True)
            ddlPOB_AffDeptList.ValueMember = "PersonId"
            ddlPOB_AffDeptList.DisplayMember = "FullName"

Here's one of the datasources I would use to populate the dept. basically the "chkselected" will be 1 if the row is selected, 0 if not:

 
  SELECT d.DeptId, d.DeptCode, d.DeptName,
   CASE
    WHEN ad.formid = @formid THEN 1
    ELSE 0
   END [chkSelected]
  FROM VW_Department d
  LEFT JOIN PTWdepts ad ON ad.PTWDeptId = d.DeptId AND (ad.formid = @formid OR @formid = '00000000-0000-0000-0000-000000000000')
  ORDER BY DeptName

Not sure how to auto popluate the grid with the selected rows from a datasource.

Parents
  • 469350
    Offline posted

    Hi,

    I'm having trouble understanding what you are asking.

    It sounds like you are currently binding the grid to a BindingList<T> and you are asking how to bind the grid to a DataSet populated from a server or other database.

    But you are already populating the dropdowns using a DataSet (presumably from a database). And there's no difference between doing this for a DropDown or a grid.

    So I don't know what your question is.

Reply Children
No Data