0

現在、asp.netを使用してリストを作成しています

<asp:RadioButtonList ID="formatOfReport" runat="server" Font-Size="Large" 
                  BorderColor="Black" 
                  onselectedindexchanged="formatOfReport_SelectedIndexChanged" 
                  style="width: 124px">
                  <asp:ListItem Selected="True">k</asp:ListItem>
                <asp:ListItem>j</asp:ListItem>

            </asp:RadioButtonList>

私はC#が初めてで、リスト項目を上記のようにプログラムで設定する方法を考えていました

4

1 に答える 1

1

たとえば、page_load次のようになります。

protected void Page_Load(object sender, EventArgs e)
{                        
    if(!IsPostBack)
    {
       var item = new ListItem("k", "k");
       item.Selected = true;
       this.formatOfReport.Items.Add(item);
       item  = new ListItem("j", "j")
       this.formatOfReport.Items.Add(item);
    }
}
于 2012-11-29T11:29:07.660 に答える