亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Jquery實(shí)現(xiàn)三層遍歷刪除功能代碼

 更新時(shí)間:2013年04月23日 17:29:09   作者:  
遍歷每一行的同時(shí)一定要記住這里是gridviewrow不是datarow,找到這個(gè)選中項(xiàng)在執(zhí)行刪除
aspx頁(yè)
復(fù)制代碼 代碼如下:

<script src="Jquery1.7.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#Checkbox1').click(function () {
if ($('#Checkbox1').is(':checked')) {
$('td input').attr('checked', true);
}
else { $('td input').attr('checked', false); }
})
$('#Checkbox2').click(function () {
$('td input').each(function () {
$(this).attr('checked', !$(this).attr('checked'))
})
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Checkbox1" type="checkbox" />全選<input id="Checkbox2" type="checkbox" />反選<asp:Button
ID="Button1" runat="server" Text="刪除" onclick="Button1_Click" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="選擇">
<ItemTemplate>
<asp:CheckBox ID="CheckBox3" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Id" HeaderText="編號(hào)" />
<asp:BoundField DataField="NewsTitle" HeaderText="標(biāo)題" />
<asp:BoundField DataField="NewsContent" HeaderText="新聞內(nèi)容">
<ItemStyle Width="200px" />
</asp:BoundField>
<asp:BoundField DataField="NewsCreator" HeaderText="創(chuàng)建者" />
<asp:BoundField DataField="CreateTime" HeaderText="創(chuàng)建時(shí)間" />
</Columns>
</asp:GridView>
</div>
</form>

后臺(tái)cs文件
復(fù)制代碼 代碼如下:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
load();
}
}
private void load()//就實(shí)現(xiàn)綁定
{
Jquery三層實(shí)現(xiàn)刪除功能.Model.T_News mm = new Model.T_News();
Jquery三層實(shí)現(xiàn)刪除功能.BLL.T_News bb = new BLL.T_News();
string sqlwhere = "Id<25";
ds = bb.GetList(sqlwhere);//獲取dataset綁定
this.GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
//遍歷每一行
foreach (GridViewRow item in GridView1.Rows)//一定要記住這里是gridviewrow不是datarow
{
CheckBox cb = (CheckBox)item.FindControl("CheckBox3");//找到這個(gè)選中項(xiàng)
if (cb.Checked)//選中
{
Jquery三層實(shí)現(xiàn)刪除功能.BLL.T_News bb = new BLL.T_News();
if (bb.DeleteList(item.Cells[1].Text))//調(diào)用bb.DeleteList(id)刪除
{
Response.Write("刪除成功");
}
load();

相關(guān)文章

最新評(píng)論