I have created a radgrid where the items are populated via a datatable. Whilst in edit mode i have created a dropdownlist of which is populated during the radgrid itemdatabound event.The dropdownlists on selectedindexchanged then populates textboxes according to what is selected, but my problem at the moment is that when the dropdown autopostbacks nothing happens as the dropdown is being repopulated again during postback. It isn't even getting to the SelectedIndexChanged fucntion.
How can I stop this from happening. hope this makes sense! here is some of the code being used.
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles radgrid.ItemDataBound
If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
Dim ddl As DropDownList = DirectCast(item.FindControl("dropdown"), DropDownList)
'Populate the dropdownlist
createDropDown(ddl)
End If
End Sub
Protected Sub ddl_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim ddl As DropDownList = DirectCast(sender, DropDownList)
Dim item As GridEditableItem = DirectCast(ddl.NamingContainer, GridEditableItem)
DimID As Integer = ddl.SelectedValue
''locate relevant textboxes
Dim txtBox As TextBox = DirectCast(item.FindControl("txtBox"), TextBox)
'Assign the data to relevant boxes
Dim dt As DataTable = riskAssessment_BLL.getGenericData(ID)
If dt.Rows.Count <> 0 Then
For Each statement As DataRow In dt.Rows
txtbox.Text = statement.Item("data").ToString()
Next
End If
dt.Dispose()
End Sub
How can I stop this from happening. hope this makes sense! here is some of the code being used.
Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles radgrid.ItemDataBound
If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
Dim ddl As DropDownList = DirectCast(item.FindControl("dropdown"), DropDownList)
'Populate the dropdownlist
createDropDown(ddl)
End If
End Sub
Protected Sub ddl_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim ddl As DropDownList = DirectCast(sender, DropDownList)
Dim item As GridEditableItem = DirectCast(ddl.NamingContainer, GridEditableItem)
DimID As Integer = ddl.SelectedValue
''locate relevant textboxes
Dim txtBox As TextBox = DirectCast(item.FindControl("txtBox"), TextBox)
'Assign the data to relevant boxes
Dim dt As DataTable = riskAssessment_BLL.getGenericData(ID)
If dt.Rows.Count <> 0 Then
For Each statement As DataRow In dt.Rows
txtbox.Text = statement.Item("data").ToString()
Next
End If
dt.Dispose()
End Sub