我试图从我的控制ItemTemplate
内部获取值。ListView1
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text="test message" />
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem Value="5">
</asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
protected void btnSubmit_Click(object sender, EventArgs e)
{
int score = 0;
foreach (ListViewItem item in RadioButtonList1.Items)
{
ListViewDataItem theValue = RadioButtonList1.Items[0];
RadioButtonList myValue = (RadioButtonList)theValue.FindControl("RadioButtonList1");
score += int.Parse(myValue.SelectedItem.Value);
}
// display score
}
有什么建议么?