I have a datagrid with a bunch of rows but only one of them can be the primary so I added a radio button to the datagrid but when I render the page the wrong row is selected. The update SQL works and updates the correct row in the database, but when I render the page the wrong radio button is selected. The value for the selected row has checked=false when I inspect the element and the correct row has a checked=true. How can I get the correct radio button to be selected when I'm already setting the checked value but it looks like it's always setting the selected value to the last row in the grid instead of the one where checked=true.
Aspx radio button column: (label that I'm using as placeholder to group the radio buttons together)
<ItemTemplate>
<asp:Label ID="rdbPrimary" Text='<%# DataBinder.Eval(Container.DataItem, "Primary")%>' Runat="server" />
</ItemTemplate>
VB datagrid databind:
Protected Sub tblCategories_SelectedIndexChanged(sender As Object, e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles tblCategories.ItemDataBound
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
Dim r As Label
Dim c As Label
r = e.Item.FindControl("rdbPrimary")
c = e.Item.FindControl("lblCategoryID")
r.Text = "<input type=radio name='myradiogroup' value=" & c.Text & " checked=" & r.Text & " >"
End If
If e.Item.ItemType.ToString() = "Footer" Then
Dim a As Label
a = e.Item.FindControl("rdbAdd")
a.Text = "<input type=radio name='myradiogroup'>"
End If
End Sub