I have a radgrid. When I go to update a record the dropdown does not populate with the value of the current record.
I understand how to set the selectedvalue, but i dont understand how to retrieve the records value for this field to set the selectedvalue to.
This is my code that isnt working. Any help is appreciated.
ASPX Code:
.VB Code:
I understand how to set the selectedvalue, but i dont understand how to retrieve the records value for this field to set the selectedvalue to.
This is my code that isnt working. Any help is appreciated.
ASPX Code:
<telerik:GridDropDownColumn DataSourceID="ReportFormatddlist" ListTextField="ReportFormat" ListValueField="ReportFormat" UniqueName="ddReportFormat" SortExpression="ReportFormat" HeaderText="Report Format" DropDownControlType="DropDownList" DataField="ReportFormat"></telerik:GridDropDownColumn>.VB Code:
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound If (TypeOf e.Item Is GridEditableItem AndAlso CType(e.Item, GridEditableItem).IsInEditMode) Then 'Report Render Format. The 3 values are just plugged into a list Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem) Dim editMan As GridEditManager = editedItem.EditManager Dim editor As GridDropDownListColumnEditor = CType(editMan.GetColumnEditor("ddReportFormat"), GridDropDownListColumnEditor) Dim ReportFormatddList As DropDownList = editor.DropDownListControl 'populate the list ReportFormatddList.Items.Insert(0, New ListItem("Excel", "Excel")) ReportFormatddList.Items.Insert(1, New ListItem("PDF", "PDF")) ReportFormatddList.Items.Insert(2, New ListItem("HTML4.0", "HTML4.0")) ReportFormatddList.DataBind() 'prime value for update
'**this is where I am having trouble**
Dim ReportFormatEditor As GridDropDownListColumnEditor = editMan.GetColumnEditor("ddReportFormat") Dim ReportFormatValue = ReportFormatEditor.SelectedText editor.SelectedText = ReportFormatValue.ToString 'Report name. The values are pulled from the db. editor = CType(editMan.GetColumnEditor("ddReportName"), GridDropDownListColumnEditor) editor.DataSource = (From r In DbContext.SubscriptionReportNames Select r).ToList() editor.DataBind() End IfEnd Sub