Here is a trick one, because IntelliSense doesn’t bring up the “SelectedValue” property for a RadioButtonList, or a DropDownList in an EditItemTemplate for GridViews you may forget that “SelectedValue” is an actual property of these controls.
Here is how you can set the selected value of a RadioButtonList inside an EditItemTemplate
[codesyntax lang=”html4strict”]
<asp:TemplateField HeaderText="Payment"> <ItemTemplate> <asp:Label ID="lablePayment" runat="server" Text='<%#Eval("PayName")%>' /> </ItemTemplate> <EditItemTemplate> <asp:RadioButtonList Runat = "server" ID="rblPaymentType" SelectedValue='<%#Eval("PayTypeID")%>'> <asp:ListItem Text="Check" Value="1"></asp:ListItem> <asp:ListItem Text="Credit Card" Value="2"></asp:ListItem> </asp:RadioButtonList> </EditItemTemplate> </asp:TemplateField>
[/codesyntax]