日期:2014-05-17 浏览次数:20392 次
protected void igb_delete_Click(object sender, ImageClickEventArgs e) { string IDlist = Common.PublicMethod.CheckCbx(this.GVdata, "chb_delete", "LabVisible"); if (IDlist.Trim() != "") { if (!Warningbll.DeleteList(IDlist)) { Response.Write("<script>alert('删除选中记录时发生错误!请重新登陆后重试!');</script>"); } else { GVdataDataBind(); } } else { this.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), " alert('请选择你要删除的项!'); ", true); return; } }
//判断GridView里面被选中的ID public static string CheckCbx(GridView GVData, string CheckBoxName, string LabID) { string str = ""; for (int i = 0; i < GVData.Rows.Count; i++) { GridViewRow row = GVData.Rows[i]; CheckBox Chk = (CheckBox)row.FindControl(CheckBoxName); Label LabVis = (Label)row.FindControl(LabID); if (Chk.Checked == true) { if (str == "") { str = LabVis.Text.ToString(); } else { str = str + "," + LabVis.Text.ToString(); } } } return str; }
<asp:ImageButton ID="BtnFirst" runat="server" CommandName="First" ImageUrl="../../images/Button/First.jpg" OnClick="PagerButtonClick" Style="height: 14px" /> <asp:ImageButton ID="BtnPre" runat="server" CommandName="Pre" ImageUrl="../../images/Button/Pre.jpg" OnClick="PagerButtonClick" Style="height: 14px" /> <asp:ImageButton ID="BtnNext" runat="server" CommandName="Next" ImageUrl="../../images/Button/Next.jpg" OnClick="PagerButtonClick" Style="width: 16px" /> <asp:ImageButton ID="BtnLast" runat="server" CommandName="Last" ImageUrl="../../images/Button/Last.jpg" OnClick="PagerButtonClick" Style="height: 14px; width: 16px;" />
string arg = ((ImageButton)sender).CommandName.ToString(); switch (arg) { case ("Next"): if (this.GVdata.PageIndex < (GVdata.PageCount - 1)) GVdata.PageIndex++; break; case ("Pre"): if (GVdata.PageIndex > 0) GVdata.PageIndex--; break; case ("Last"):