This is a migrated thread and some comments may be shown as answers.

Radgrid dropdown autopostback in edit mode

1 Answer 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
K W
Top achievements
Rank 1
K W asked on 28 Aug 2014, 09:04 AM
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
 




1 Answer, 1 is accepted

Sort by
0
K W
Top achievements
Rank 1
answered on 28 Aug 2014, 09:59 AM
I have now sorted this thanks. 

I changed the way I bound my radgrid. 
I used the 'NeedDataSource' and it then worked.

http://www.telerik.com/help/aspnet-ajax/grid-binding-to-datatable-or-dataset.html

Tags
Grid
Asked by
K W
Top achievements
Rank 1
Answers by
K W
Top achievements
Rank 1
Share this question
or