I have searched and searched and all available solutions are not working for me.
I have a RadGrid that I am databinding at runtime. Each time I select a row, it will fire the SelectedIndexChanged, but I get an index error or the value selected is nothing. I'm at my wits end here and I'm not sure how to proceed.
Here's my aspx page:
And here's my vb code:
I have tried using a button as well to fire the event. This doesn't seem to be the issue, as the event fires, I just can't get the value selected. Any help here would be greatly appreciated.
I have a RadGrid that I am databinding at runtime. Each time I select a row, it will fire the SelectedIndexChanged, but I get an index error or the value selected is nothing. I'm at my wits end here and I'm not sure how to proceed.
Here's my aspx page:
| <asp:Panel runat="server" ID="DrugList" Height="370px" Width="550" ScrollBars="Auto"> |
| <telerik:RadGrid ID="rgDrugList" runat="server" AllowMultiRowSelection="True" |
| AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" GridLines="None" |
| Height="350px" OnItemCommand="rgDrugList_ItemCommand" |
| Skin="Vista" Width="545px" OnselectedIndexChanged="rgDrugList_SelectedIndexChanged"> |
| <MasterTableView> |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| <Columns> |
| <telerik:GridBoundColumn DataField="Name" HeaderText="Drug Name" SortExpression="Name" UniqueName="Name"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings EnablePostBackOnRowClick="true"> |
| <Selecting AllowRowSelect="True" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
| </asp:Panel> |
And here's my vb code:
| Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load |
| InitializeData() |
| End Sub |
| Protected Sub InitializeData() |
| Dim o As New localhost.Service1 |
| Dim ds As New DataSet |
| ds = o.GetNumbderDrugData |
| If ds Is Nothing Then |
| errorPanel.Visible = True |
| Exit Sub |
| End If |
| If ds.Tables(0).Rows.Count = 0 Then |
| errorPanel.Visible = True |
| Exit Sub |
| Else |
| errorPanel.Visible = False |
| rgDrugList.DataSource = ds |
| rgDrugList.DataBind() |
| End If |
| End Sub |
| Protected Sub rgDrugList_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rgDrugList.SelectedIndexChanged |
| Dim item As GridDataItem = DirectCast(rgDrugList.SelectedItems(0), GridDataItem) |
| ' Get the first selected item |
| If True Then |
| MsgBox(item("Name").Text) |
| End If |
| End Sub |
I have tried using a button as well to fire the event. This doesn't seem to be the issue, as the event fires, I just can't get the value selected. Any help here would be greatly appreciated.