K
kaczmar2
I have the following code, which
1) grabs data from a database
2) appends a data row to the data set
3) sorts the data
I cannot get the data to sort. Everything is working fine
execeptDefaultView.Sort method is inneffective. The code is below:
' rbl = RadioButtonList
ds = CreateDataSource() ' returns a dataset
' Add N/A option
drRow = ds.Tables("Accessories").NewRow
drRow.Item("AccessoryID") = -1
drRow.Item("Accessory") = "N/A"
ds.Tables("Accessories").Rows.Add(drRow)
ds.Tables("Accessories").DefaultView.Sort = "AccessoryID"
rbl.DataSource = ds
rbl.DataMember = "Accessories"
rbl.DataTextField = "Accessory"
rbl.DataValueField = "AccessoryID"
rbl.DataBind()
rbl.SelectedIndex = 0
Everything is working but the sorting. I need it to sort by ID, since
I add a "N/A" option with ID of -1, and then select the first index of
the control.
Any tips would be appreciated.
1) grabs data from a database
2) appends a data row to the data set
3) sorts the data
I cannot get the data to sort. Everything is working fine
execeptDefaultView.Sort method is inneffective. The code is below:
' rbl = RadioButtonList
ds = CreateDataSource() ' returns a dataset
' Add N/A option
drRow = ds.Tables("Accessories").NewRow
drRow.Item("AccessoryID") = -1
drRow.Item("Accessory") = "N/A"
ds.Tables("Accessories").Rows.Add(drRow)
ds.Tables("Accessories").DefaultView.Sort = "AccessoryID"
rbl.DataSource = ds
rbl.DataMember = "Accessories"
rbl.DataTextField = "Accessory"
rbl.DataValueField = "AccessoryID"
rbl.DataBind()
rbl.SelectedIndex = 0
Everything is working but the sorting. I need it to sort by ID, since
I add a "N/A" option with ID of -1, and then select the first index of
the control.
Any tips would be appreciated.