<asp:Button ID="btnDelete" runat="server" Text="删除所有" onclick="btnDelete_Click" /><asp:Repeater ID="repAlbum_List" runat="server">
<ItemTemplate>
<li>
<div style="float:left">
<asp:CheckBox ID="chkchild" name="chkchild" runat="server" Text="" />
<a href="#"><%#Eval("title") %></a><br />
</div>
</li>
</ItemTemplate>
</asp:Repeater>
后台:
protected void btnDelete_Click(object sender, EventArgs e)
{
MusicRules mr = new MusicRules();
for (int i = 0; i < repAlbum_List.Items.Count; i++)
{
CheckBox chkchild = (CheckBox)(repAlbum_List.Items[i].FindControl("chkchild"));
if (chkchild.Checked)
{ HiddenField hidid = (HiddenField)repAlbum_List.Items[i].FindControl("hidid");
if (mr.DeletePhoto(Convert.ToInt32(hidid.Value)))
{
int page = Request.QueryString["page"] == null ? 1 : Convert.ToInt32(Request.QueryString["page"]);
ScriptManager.RegisterClientScriptBlock(repAlbum_List, GetType(), "xxx", "alert('删除成功!');", true);
this.repAlbum_List.DataSource = pr.Search_Photo(this.txtAlbum.Text, page, pagesize, out sumcount);
this.repAlbum_List.DataBind();
}
}
}
}当选中CheckBox时,它还是为Checked=false,求高手,求解释。
<ItemTemplate>
<li>
<div style="float:left">
<asp:CheckBox ID="chkchild" name="chkchild" runat="server" Text="" />
<a href="#"><%#Eval("title") %></a><br />
</div>
</li>
</ItemTemplate>
</asp:Repeater>
后台:
protected void btnDelete_Click(object sender, EventArgs e)
{
MusicRules mr = new MusicRules();
for (int i = 0; i < repAlbum_List.Items.Count; i++)
{
CheckBox chkchild = (CheckBox)(repAlbum_List.Items[i].FindControl("chkchild"));
if (chkchild.Checked)
{ HiddenField hidid = (HiddenField)repAlbum_List.Items[i].FindControl("hidid");
if (mr.DeletePhoto(Convert.ToInt32(hidid.Value)))
{
int page = Request.QueryString["page"] == null ? 1 : Convert.ToInt32(Request.QueryString["page"]);
ScriptManager.RegisterClientScriptBlock(repAlbum_List, GetType(), "xxx", "alert('删除成功!');", true);
this.repAlbum_List.DataSource = pr.Search_Photo(this.txtAlbum.Text, page, pagesize, out sumcount);
this.repAlbum_List.DataBind();
}
}
}
}当选中CheckBox时,它还是为Checked=false,求高手,求解释。
解决方案 »
- System.Data.SqlClient.SqlException: '?' 附近有语法错误。
- 如何用js来写一个导航树?点击树节点能传值??急!!!
- 如何在网页中加入flv文件,使它能在网页中播放
- 初学者提问:web网站源代码下到本机后,很多错误!
- cassini报错
- 关于 Asp.net 中 Repeater 内绑定了一个Button 的问题.
- 在ACCESS如何实现模糊查询 用的是OLE连接
- 请各位帮解决下图片不间断滚动的问题,谢谢!
- 打开和创建web应用程序时遇到的速度问题
- .NET MVC 如何在post action中添加一个弹出窗口
- windows2003如何做负载平衡(双网卡(单卡双线))?
- .aspx.cs调用.cs静态类问题.
<asp:Repeater ID="repAlbum_List" runat="server">
<ItemTemplate>的数据集在前面加入
if(!IsPostBack)//是否首次加载
{
//绑定<asp:Repeater的数据集
}