Hi,
I have a hierarchical grid, which is bound to a dataset via the DataBind method.
On certain columns I have to display the text in stead of numbers.
I do this at the moment in creating valuelists for these columns by looping thru the rows of a datatable.
Somtimes I need the same valuelists in two columns but different bands or even in two grids on the same form.
To get this working I have to clone the valulists otherwise I get a runtime error.
I'm wondering if there is no way to bind a valuelist of acolumn directly to the dataset.
i'v built this function with 4 overloads, you pass a dt it returns as valuelist
Return getLookupValueList(lkpdt, displayCol, isExpr, String.Empty, False)
Return getLookupValueList(lkpDT, displayCol, isExpr, filter, False)
Return getLookupValueList(lkpDT, displayCol, isExpr, String.Empty, sort)
End Function
'same as above, but it filters the datatable by the given filter value
If isExpr Then
displayCol = "expr"
End If
If filter = String.Empty Then
If sort = True Then
myRows = lkpDT.Select("TRUE=TRUE", displayCol)
Else
myRows = lkpDT.Select()
myRows = lkpDT.Select(filter, displayCol)
myRows = lkpDT.Select(filter)
myVL.Key = lkpDT.TableName
If Not row.RowState = DataRowState.Deleted Then myVL.ValueListItems.Add(row.Item(0), row.Item(displayCol).ToString)
Next
If myVL.ValueListItems.Count = 0 Then
myVL.ValueListItems.Add(0, "**No Items In List**")
lkpDT.Columns.Remove("expr")
That is a quite nice solution.
Havn't thought on doing it this way.
But anyway it would be much easier if You could bind it like on a combo box.
Many Thanks
I try to fiure it on my solution