I have a radgrid that is being dynamically created, adding 1 row at a time. One of the columns is a radcombobox which is filled using LINQ. The prerender event is set for the grid to make all rows editable (for multirowedit functionality). All of that works fine...the problem is that each time I add a new row to the grid the selectedvalue of the radcombobox for previously entered rows changes to match the selectedvalue for the new row. How do i get each combobox in each row to retain its correct selectedvalue? To clarify...the selection of each radcombobox is set using: rcb.Text = "SelectedValueText" where "SelectedValueText" is a value which appears in the radcombobox. I'm thinking the issue has to do with the prerender event calling rebind which executes itemdatabound for each row in the grid but i'm not sure how to make all columns in a row editable on the row level (as each row is added) as opposed to on the gridlevel. Can you iterate through the cells in a single row to put in edit mode from within the ItemDataBound event?
Code: VB
Private Sub rgDataEntry_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgDataEntry.ItemDataBound
If (Session("DataEntry") Is Nothing) Then
CreateDataTable()
End If
If (TypeOf e.Item Is GridEditableItem And e.Item.IsInEditMode) Then
Dim item As GridEditableItem = CType(e.Item, GridEditableItem)
Dim rcb As RadComboBox = CType(item.FindControl("cboFundingCodeEdit"), RadComboBox)
Dim db As EcotAppsDataContext = New EcotAppsDataContext
Dim query = From codes In db.FundingCodes
Select codes.FundingCode, codes.FundingCodeID Order By FundingCode Order By FundingCode
For Each x In query
Dim rcbItem As New RadComboBoxItem(x.FundingCode.ToString)
rcb.Items.Add(rcbItem)
Next
Dim rcbDefaultItem As New RadComboBoxItem(String.Empty)
rcb.Items.Insert(0, rcbDefaultItem)
Dim FundCode As String
FundCode = Convert.ToString(Session("FundingCode"))
rcb.Text = FundCode
End If
End Sub
Private Sub rgDataEntry_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles rgDataEntry.PreRender
If (Session("DataEntry") Is Nothing) Then
CreateDataTable()
End If
For Each item As GridItem In rgDataEntry.MasterTableView.Items
If TypeOf item Is GridEditableItem Then
Dim editableItem As GridEditableItem = CType(item, GridDataItem)
editableItem.Edit = True
End If
Next
rgDataEntry.Rebind()
End Sub