Hi I have a dyna开发者_开发知识库mic radiobutton
aspx-file
<asp:RadioButtonList ID="MoneyTransfer" runat="server" CssClass="darkgrey">
</asp:RadioButtonList>
aspx.cs-file
MoneyTransfer.Items.Add(new ListItem("BankTransfer","BankTransfer", true));
MoneyTransfer.Items.Add(new ListItem("PayPal","PayPal", true));
What do I have to do to get the first listItem to be the selected one ?
Set Selected Property of listItem to true.
ListItem ls =new ListItem("BankTransfer", "BankTransfer" ,true);
ls.Selected=true;
ListItem ls2 = new ListItem("PayPal", "PayPal", true);
MoneyTransfer.Items.Add(ls);
MoneyTransfer.Items.Add(ls2);
Have you tried?
MoneyTransfer.SelectedIndex = 0;
精彩评论