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
230
ValueList inserts a null, or nothing value, rather than the item I select
posted

My vb.net project includes a form with an Infragistics UltraGrid, in which one column, "Product_Code"` is a `DropDownList` style, populated by a ValueList.

What happens is, on the first row of the grid (Index 0), the item I select fills in the in the grid, and I can enter the rest of the data as I wish to.

However, when I add a second row (index 1 or higher), the ValueList remains the same, but whenever I click on a value, it inserts a `Null` or `Nothing` value into the "Product_Code" column. Is there anything alarmingly obvious which I'm doing wrong here?

I can't work out why this is happening

ugProducts.UpdateData()

For Each ugr In ugProducts.Rows
If ugr.Cells("Product_Code").Value = ugProducts.Rows(ugProducts.Rows.Count - 1).Cells("Product_Code").Value And ugr.Index <> ugProducts.Rows(ugProducts.Rows.Count - 1).Index Then
MsgBox("Cannot add the same product twice", MsgBoxStyle.OkOnly, "Error adding product")
ugProducts.Rows(ugProducts.Rows.Count - 1).Delete(False)
Exit Sub
End If
Next

Try
If supplier = "" Then
sql = "SELECT [Base_Code] FROM [Products]"
dtProducts = getDT(sql)

For Each dr In dtProducts.Rows
vlProducts.ValueListItems.Add(dr.Item("Base_Code"), dr.Item("Base_Code"))
Next
Else
Dim ProductsDt As New DataTable

Using ProductsDa = New OleDbDataAdapter("SELECT [Product_Code] FROM [Product Suppliers] WHERE Supplier_Code=?", con)
ProductsDa.SelectCommand.Parameters.Add("@suppliercode", OleDbType.VarChar).Value = supplier
ProductsDa.Fill(ProductsDt)
End Using

vlProducts.ValueListItems.Clear()

For Each dr In ProductsDt.Rows
vlProducts.ValueListItems.Add(dr.Item("Product_Code"), dr.Item("Product_Code"))
Next
ugProducts.DisplayLayout.Rows(0).Cells("Product_Code").ValueList = vlProducts
End If

Parents
No Data
Reply
  • 12480
    Offline posted

    Hi David,

    In the code above, the value list is only added to the first row. Rather than adding the value list to the cell, you can add it to the column.

    ugProducts.DisplayLayout.Bands[0].Columns[0].ValueList = vlProducts

    Please try this out and let me know if it works.

Children