我写了个DataList
<asp:datalist id="DataList1" runat="server" Height="41" Width="209">
<ItemTemplate>
<table>
<tr>
<td><%# DataBinder.Eval(Container.DataItem,"Serial")%>
, <%# DataBinder.Eval(Container.DataItem,"Subject")%></td>
</tr>
<tr>
<td>
<asp:Label ID="answer" Runat="server">
<%# DataBinder.Eval(Container.DataItem,"Answer")%>
<asp:Label ID="QuestionId" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"QuestionId")%>' Visible=False>
</asp:Label>
</td>
</tr>
<tr>
<td>
<asp:RadioButtonList ID="sSelAnswer" Runat="server" RepeatDirection="Horizontal"></asp:RadioButtonList></td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>
也就是DataList的每个Item都有一个RadioButtonList,现在我要获取每个RadioButtonList的选定值,
该怎么做啊
<asp:datalist id="DataList1" runat="server" Height="41" Width="209">
<ItemTemplate>
<table>
<tr>
<td><%# DataBinder.Eval(Container.DataItem,"Serial")%>
, <%# DataBinder.Eval(Container.DataItem,"Subject")%></td>
</tr>
<tr>
<td>
<asp:Label ID="answer" Runat="server">
<%# DataBinder.Eval(Container.DataItem,"Answer")%>
<asp:Label ID="QuestionId" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"QuestionId")%>' Visible=False>
</asp:Label>
</td>
</tr>
<tr>
<td>
<asp:RadioButtonList ID="sSelAnswer" Runat="server" RepeatDirection="Horizontal"></asp:RadioButtonList></td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>
也就是DataList的每个Item都有一个RadioButtonList,现在我要获取每个RadioButtonList的选定值,
该怎么做啊
foreach(DataListItem oItem in DataList1.Items)
{
RadioButtonList myCL=(RadioButtonList)oItem.FindControl("RadioButtonList1");
foreach(ListItem ThisOne in myCL.Items)
{
if(ThisOne.Selected)
{
//ThisOne.Value
}
else
{ }
}
}
谢谢
我还想问一下,如果我在DataList的每各item中放若干文本框,放多少个的个数取自数据库,这该怎么做啊
该怎么做啊
比较急,谢谢