62,047
社区成员
发帖
与我相关
我的任务
分享
<asp:DataList ID="DataList1" runat="server" DataKeyField="testitemid">
<ItemTemplate>
<asp:Label ID="itemnameLabel" runat="server" Text='<%# Eval("itemname") %>'></asp:Label><br />
<asp:RadioButton ID="RadioButton1" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select1") %>' ToolTip='<%# Eval("score1") %>' />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select2") %>' ToolTip='<%# Eval("score2") %>' />
<asp:RadioButton ID="RadioButton3" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select3") %>' ToolTip='<%# Eval("score3") %>' />
<asp:RadioButton ID="RadioButton4" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select4") %>' ToolTip='<%# Eval("score4") %>' />
<asp:RadioButton ID="RadioButton5" runat="server" GroupName='<%# Eval("itemname") %>' Text='<%# Eval("select5") %>' ToolTip='<%# Eval("score5") %>' />
</ItemTemplate>
<SeparatorTemplate><hr /></SeparatorTemplate>
</asp:DataList>
</div>
<div><asp:Label ID="teststatement" runat="server"></asp:Label></div>
<asp:Button ID="submit" runat="server" Text="完成" OnClick="submit_Click" />
protected void submit_Click(object sender, EventArgs e)
{
int score;
foreach (DataListItem dli in DataList1.Items)
{
RadioButton rbtn1 = (RadioButton)DataList1.Items[0].FindControl("RadioButton1");
RadioButton rbtn2 = (RadioButton)DataList1.Items[0].FindControl("RadioButton2");
RadioButton rbtn3 = (RadioButton)DataList1.Items[0].FindControl("RadioButton3");
RadioButton rbtn4 = (RadioButton)DataList1.Items[0].FindControl("RadioButton4");
RadioButton rbtn5 = (RadioButton)DataList1.Items[0].FindControl("RadioButton5");
if (rbtn1.Checked == true)
{
score = System.Convert.ToInt32(ds.Tables["test_temp1"].DefaultView[0].Row[4]);
}
if (rbtn2.Checked == true)
{
score = System.Convert.ToInt32(ds.Tables["test_temp1"].DefaultView[0].Row[6]);
}
if (rbtn3.Checked == true)
{
score = System.Convert.ToInt32(ds.Tables["test_temp1"].DefaultView[0].Row[8]);
}
if (rbtn4.Checked == true)
{
score = System.Convert.ToInt32(ds.Tables["test_temp1"].DefaultView[0].Row[10]);
}
if (rbtn5.Checked == true)
{
score = System.Convert.ToInt32(ds.Tables["test_temp1"].DefaultView[0].Row[12]);
}
if (rbtn1.Checked == false && rbtn2.Checked == false && rbtn3.Checked == false && rbtn4.Checked == false && rbtn5.Checked == false)
{
Response.Write("<script language='javascript'>alert('您还没有完成,请重新选择');</script>");
return;
}
Response.Write(score);
Response.Write("<br />");
}
}
foreach (DataListItem item in DataList1.Items)
{
RadioButton radButton1 = (RadioButton)item.FindControl("RadioButton1");
RadioButton radButton2 = (RadioButton)item.FindControl("RadioButton2");
RadioButton radButton3 = (RadioButton)item.FindControl("RadioButton3");
RadioButton radButton4 = (RadioButton)item.FindControl("RadioButton4");
RadioButton radButton5 = (RadioButton)item.FindControl("RadioButton5");
}