<script language="javascript" type="text/javascript" src="http://www.cnblogs.com/js/JQuery/jquery-1.4.1-vsdoc.js"></script>
<script type="text/javascript" defer="defer">
//全选的脚本
$(function()
{
$("#chkAll").click(function()
{
if($(this).attr("checked")==true)
{
//对于checkBox是.net服务器控件时可以这样做,$(":checkbox").each(function(){});
$("input[name='chkBulletin']").each(function()
{
$(this).attr("checked",true);
});
}
else
{
//对于checkBox是.net服务器控件时可以这样做,$(":checkbox").each(function(){});
$("input[name='chkBulletin']").each(function()
{
$(this).attr("checked",false);
});
}
});
});
//批量删除保存所选项的ID的脚本
function Delete()
{
if(confirm("确定删除吗?")==true)
{
var text="";
//对于checkBox是.net服务器控件时可以这样做,$(":checkbox").each(function(){});
$("input[name='chkBulletin']").each(function()
{
if($(this).attr("checked")==true)
{
text += $(this).val() +";";
}
});
if(text=="")
{
alert("请选择要删除的数据!");
return false;
}
else
{
var tempText = text.substring(0, text.length - 1);
$('#<%=hfBulletinID.ClientID %>').val(tempText);
}
alert($('#<%=hfBulletinID.ClientID %>').val());
return true;
}
else
{
return false;
}
}
</script>
<table>
<tr>
<td valign="top" class="headerButtonsTopPadding">
<asp:ImageButton ID="ibtnBatchDelete" runat="server" ImageUrl="~/images/icon/icon-delete.gif"
OnClientClick='Delete();' οnclick="ibtnBatchDelete_Click" />批量删除
</td>
</tr>
<tr>
<td valign="top">
<asp:GridView ID="gvBulletin" runat="server" Width="100%" AutoGenerateColumns="False" DataKeyNames="ID" CssClass="Grid" >
<Columns>
<asp:TemplateField>
<HeaderTemplate><input type="checkbox" id="chkAll" name="chkAll" value="全选" /></HeaderTemplate>
<ItemTemplate >
<input type="checkbox" id="chkBulletin" value='<%#Eval("ID") %>' name="chkBulletin" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" HeaderText="公告ID" Visible="False">
<HeaderStyle Wrap="False" />
</asp:BoundField>
<asp:HyperLinkField DataNavigateUrlFields="ID"
DataNavigateUrlFormatString="~/Pages/Bulletin/BulletinDetail.aspx?id={0}"
DataTextField="Title" HeaderText="标题" />
<asp:TemplateField HeaderText="摘要">
<ItemTemplate>
<asp:Label ID="lblContent" runat="server" Text='<%# SetContents(Eval("Contents"))%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Type" HeaderText="类型" ></asp:BoundField>
<asp:TemplateField HeaderText="阅读人员">
<ItemTemplate>
<asp:Label ID="lblReader" runat="server" Text='<%# SetReader(Eval("ReaderList")) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CreatedDate" HeaderText="发布日期" HtmlEncode=false
DataFormatString="{0:yyyy-MM-dd}"></asp:BoundField>
<asp:TemplateField HeaderText="状态">
<ItemTemplate>
<asp:Label ID="lblStatus" runat="server" Text='<%# Eval("Status").ToString()!=""?Eval("Status").ToString()=="True"?"已发布":"未发布":"" %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<div>
<nobr>
<img alt="修改公告" src="http://images.cnblogs.com/ToolBar/toolbaredit.gif"
οnclick="UniversalOpenWindowAndBreak(600,500,'BulletinEdit.aspx?bulletinId=<%#Eval("ID") %>',1)"/ >
<asp:LinkButton ID="lkBtnDelete" runat="server"
OnClientClick='javascritp:return confirm("确定要删除这条公告吗?");'
οnclick="lkBtnDelete_Click" >删除</asp:LinkButton>
</nobr>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
//如下是后台得到所选项的ID代码:
string bulletinId = hfBulletinID.Value;
string[] bulletinArr = bulletinId.Split(new char[] { ';' });//转换为数据