asp.net中repeater嵌套CheckBoxList,RadioButtonList来完成投票
2010-06-13 11:18
176 查看
我们在做复式投票的时候。会遇到标题和选项嵌套的样子,下面我把我的代码放上来。 1,投票选择前台页面 view plaincopy to clipboardprint?
<table height="286" cellSpacing="0" cellPadding="0" width="1000" align="center" bgColor="#ffffff"
border="0">
<tbody>
<tr>
<td vAlign="top" height="286">
<div align="left">
<table height="32" cellSpacing="0" cellPadding="0" width="968" align="center" border="0">
<tbody>
<tr>
<td>
<div align="center"></div>
<div align="center"><strong><%=Title%></strong><br>
</div>
</td>
</tr>
</tbody>
</table>
<table cellSpacing="0" cellPadding="0" width="915" align="center" border="0">
<tbody>
<tr>
<td background="../../images/house4_07.jpg" height="1"><FONT face="宋体"></FONT></td>
</tr>
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="915" border="0">
<asp:repeater id="Repeater1" Runat="server">
<ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container, "DataItem.FVoteName") %>
<table width="85%" align="center" border="1" bordercolor="#D6E7FF" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:CheckBoxList id="cb" Runat="server" Visible="False"></asp:CheckBoxList>
<asp:RadioButtonList ID="rb" Runat="server" Visible="False"></asp:RadioButtonList>
<asp:TextBox ID="tb" TextMode="MultiLine" Columns="40" Rows="4" Runat="server" Visible="False"></asp:TextBox>
<input type="hidden" id="hb" runat="server" />
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
</asp:repeater></table>
</td>
</tr>
<tr>
<td align="center"><asp:button id="btnAdd" runat="server" Text="提交"></asp:button></td>
</tr>
</tbody>
</table>
</div>
<div align="right"></div>
</td>
</tr>
</tbody>
</table>
<table height="286" cellSpacing="0" cellPadding="0" width="1000" align="center" bgColor="#ffffff"
border="0">
<tbody>
<tr>
<td vAlign="top" height="286">
<div align="left">
<table height="32" cellSpacing="0" cellPadding="0" width="968" align="center" border="0">
<tbody>
<tr>
<td>
<div align="center"></div>
<div align="center"><strong><%=Title%></strong><br>
</div>
</td>
</tr>
</tbody>
</table>
<table cellSpacing="0" cellPadding="0" width="915" align="center" border="0">
<tbody>
<tr>
<td background="../../images/house4_07.jpg" height="1"><FONT face="宋体"></FONT></td>
</tr>
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="915" border="0">
<asp:repeater id="Repeater1" Runat="server">
<ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container, "DataItem.FVoteName") %>
<table width="85%" align="center" border="1" bordercolor="#D6E7FF" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:CheckBoxList id="cb" Runat="server" Visible="False"></asp:CheckBoxList>
<asp:RadioButtonList ID="rb" Runat="server" Visible="False"></asp:RadioButtonList>
<asp:TextBox ID="tb" TextMode="MultiLine" Columns="40" Rows="4" Runat="server" Visible="False"></asp:TextBox>
<input type="hidden" id="hb" runat="server" />
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
</asp:repeater></table>
</td>
</tr>
<tr>
<td align="center"><asp:button id="btnAdd" runat="server" Text="提交"></asp:button></td>
</tr>
</tbody>
</table>
</div>
<div align="right"></div>
</td>
</tr>
</tbody>
</table>2,后台代码 view plaincopy to clipboardprint?
<PRE class=csharp name="code">protected System.Web.UI.WebControls.Repeater Repeater1;
public Seaskyer.Modules.Utils.DBClass db = new Seaskyer.Modules.Utils.DBClass();
protected System.Web.UI.WebControls.Button btnAdd;
public string Title;
//public string cid;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
string cid = "";
if(db.q("id")!="")
{
cid=db.q("id");
}
Title = db.getSingleValue("cms_VotePro","FProName","FID",cid);
BindRep();
}
}
/// <summary>
/// 绑定Repeater控件,显示调查中的大类
/// </summary>
public void BindRep()
{
string strsql = "select * from cms_vote where FProID='"+db.q("id")+"'";
db.dp.CommandText = strsql;
DataTable dt = db.dp.DataTableSQL();
if(dt.Rows.Count>0)
{
this.Repeater1.DataSource = dt;
this.Repeater1.DataBind();
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
//
<table height="286" cellSpacing="0" cellPadding="0" width="1000" align="center" bgColor="#ffffff"
border="0">
<tbody>
<tr>
<td vAlign="top" height="286">
<div align="left">
<table height="32" cellSpacing="0" cellPadding="0" width="968" align="center" border="0">
<tbody>
<tr>
<td>
<div align="center"></div>
<div align="center"><strong><%=Title%></strong><br>
</div>
</td>
</tr>
</tbody>
</table>
<table cellSpacing="0" cellPadding="0" width="915" align="center" border="0">
<tbody>
<tr>
<td background="../../images/house4_07.jpg" height="1"><FONT face="宋体"></FONT></td>
</tr>
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="915" border="0">
<asp:repeater id="Repeater1" Runat="server">
<ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container, "DataItem.FVoteName") %>
<table width="85%" align="center" border="1" bordercolor="#D6E7FF" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:CheckBoxList id="cb" Runat="server" Visible="False"></asp:CheckBoxList>
<asp:RadioButtonList ID="rb" Runat="server" Visible="False"></asp:RadioButtonList>
<asp:TextBox ID="tb" TextMode="MultiLine" Columns="40" Rows="4" Runat="server" Visible="False"></asp:TextBox>
<input type="hidden" id="hb" runat="server" />
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
</asp:repeater></table>
</td>
</tr>
<tr>
<td align="center"><asp:button id="btnAdd" runat="server" Text="提交"></asp:button></td>
</tr>
</tbody>
</table>
</div>
<div align="right"></div>
</td>
</tr>
</tbody>
</table>
<table height="286" cellSpacing="0" cellPadding="0" width="1000" align="center" bgColor="#ffffff"
border="0">
<tbody>
<tr>
<td vAlign="top" height="286">
<div align="left">
<table height="32" cellSpacing="0" cellPadding="0" width="968" align="center" border="0">
<tbody>
<tr>
<td>
<div align="center"></div>
<div align="center"><strong><%=Title%></strong><br>
</div>
</td>
</tr>
</tbody>
</table>
<table cellSpacing="0" cellPadding="0" width="915" align="center" border="0">
<tbody>
<tr>
<td background="../../images/house4_07.jpg" height="1"><FONT face="宋体"></FONT></td>
</tr>
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="915" border="0">
<asp:repeater id="Repeater1" Runat="server">
<ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container, "DataItem.FVoteName") %>
<table width="85%" align="center" border="1" bordercolor="#D6E7FF" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:CheckBoxList id="cb" Runat="server" Visible="False"></asp:CheckBoxList>
<asp:RadioButtonList ID="rb" Runat="server" Visible="False"></asp:RadioButtonList>
<asp:TextBox ID="tb" TextMode="MultiLine" Columns="40" Rows="4" Runat="server" Visible="False"></asp:TextBox>
<input type="hidden" id="hb" runat="server" />
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
</asp:repeater></table>
</td>
</tr>
<tr>
<td align="center"><asp:button id="btnAdd" runat="server" Text="提交"></asp:button></td>
</tr>
</tbody>
</table>
</div>
<div align="right"></div>
</td>
</tr>
</tbody>
</table>2,后台代码 view plaincopy to clipboardprint?
<PRE class=csharp name="code">protected System.Web.UI.WebControls.Repeater Repeater1;
public Seaskyer.Modules.Utils.DBClass db = new Seaskyer.Modules.Utils.DBClass();
protected System.Web.UI.WebControls.Button btnAdd;
public string Title;
//public string cid;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
string cid = "";
if(db.q("id")!="")
{
cid=db.q("id");
}
Title = db.getSingleValue("cms_VotePro","FProName","FID",cid);
BindRep();
}
}
/// <summary>
/// 绑定Repeater控件,显示调查中的大类
/// </summary>
public void BindRep()
{
string strsql = "select * from cms_vote where FProID='"+db.q("id")+"'";
db.dp.CommandText = strsql;
DataTable dt = db.dp.DataTableSQL();
if(dt.Rows.Count>0)
{
this.Repeater1.DataSource = dt;
this.Repeater1.DataBind();
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
//
相关文章推荐
- asp.net中repeater嵌套CheckBoxList,RadioButtonList来完成投票
- asp.net中repeater嵌套CheckBoxList,RadioButtonList来完成投票
- asp.net中repeater嵌套CheckBoxList,RadioButtonList来完成投票
- asp.net中repeater嵌套CheckBoxList,RadioButtonList来完成投票
- asp.net中repeater嵌套CheckBoxList,RadioButtonList来完成投票
- asp.net中repeater嵌套CheckBoxList,RadioButtonList来完成投票
- [我的ASP.net学习历程]CheckBoxList和RadioButtonList的数据梆定
- ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
- ASP.NET的checkboxlist,RadioButtonList,FileUpload,image控件的综合使用
- ASP.Net: 为 CheckBoxList 和 RadioButtonList 中的各 ListItem 项目编写客户端脚本
- ASP.NET MVC 3.0 知识记要(2)【RadioButtonList、CheckBoxList】
- ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
- 在ASP.NET MVC中使用“RadioButtonList”和“CheckBoxList”
- ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
- Asp.Net Repeater的两层嵌套以及遍历取值的简单实现(checkbox)
- ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
- ASP.NET中 RadioButtonList(单选按钮组),CheckBoxList(复选框组),DropDownList(下拉框),ListBox(列表框),BulletedList(无序列表)的使用前台绑定
- ASP.NET MVC 中使用“RadioButtonList”和“CheckBoxList”
- 在ASP.NET MVC中使用“RadioButtonList”和“CheckBoxList”
- ASP.NET页面的CheckBoxList组件(资料)