复制代码 代码如下:
<div>
广大网友对保障房建设相关问题调查<br />
<asp:Repeater runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<table>
<tr>
<td colspan="3">
<b>
<%# Eval("t_timu")%>
<asp:Literal Text='<%# Eval("t_id")%>' runat="server"></asp:Literal>
</b>
</td>
</tr>
<tr>
<asp:RadioButtonList runat="server" RepeatDirection="Horizontal">
</asp:RadioButtonList>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
<br />
<asp:Button runat="server" Text="提交" />
<asp:Button runat="server" Text="查看结果" />
</div>
复制代码 代码如下:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Literal Literal1 = (Literal)e.Item.FindControl("Literal1");
RadioButtonList RadioButtonList1 = (RadioButtonList)e.Item.FindControl("RadioButtonList1");
RadioButtonList1.DataSource = dcw_toupiao_M.dcw_toupiao_getxuanxian(Convert.ToInt32(Literal1.Text));
RadioButtonList1.DataTextField = "x_name";
RadioButtonList1.DataValueField = "x_id";
RadioButtonList1.DataBind();
}
复制代码 代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
string zifu = "";
string Pid = "";
int tiaoshu = 5;
foreach (RepeaterItem iemt in Repeater1.Items)
{
RadioButtonList rbtn = iemt.FindControl("RadioButtonList1") as RadioButtonList;
try
{
if (rbtn.SelectedItem.Selected)
{
zifu += rbtn.SelectedItem.Value + ",";
}
Literal Literal1 = (Literal)iemt.FindControl("Literal1"); //e.Item.FindControl("");
if (Literal1.Text != "")
{
Pid += Literal1.Text + ",";
}
}
catch (Exception ex)
{
}
}
string[] xid = null;
xid = zifu.TrimEnd(',').Split(',');
string[] pid = null;
pid = Pid.TrimEnd(',').Split(',');
if (dcw_toupiao_M.dcw_toupiao_Insert(xid, pid, tiaoshu))
{
this.ClientScript.RegisterClientScriptBlock(typeof(string), "ok", "<script>alert('投票成功!谢谢参与')</script>");
}
else
{
this.ClientScript.RegisterClientScriptBlock(typeof(string), "ok", "<script>alert('请完成选择')</script>");
}
}
复制代码 代码如下:
public static bool dcw_toupiao_Insert(string[] xid, string[] pid, int tiaoshu)
{
bool flag = false;
for (int i = 0; i < pid.Length; i++)
{
SqlParameter[] prm = new SqlParameter[2];
prm[0] = new SqlParameter("@xid", Int32.Parse(xid[i]));
prm[1] = new SqlParameter("@pid", Int32.Parse(pid[i]));
if (dcw_toupiao_M.dcw_toupiao_gettcount(Convert.ToInt32(xid[i]), Convert.ToInt32(pid[i])))
{
flag = _dc_toupiao_DB.SqlHelper.ExeucteNonQuery("sm_dcw_toupiao_Insert", CommandType.StoredProcedure, prm) > 0;
}
}
return flag;
}
新闻热点
疑难解答
图片精选