本人实现时主要难点是,不知道怎么得到复选框选中了那些记录ID号,刚初学,谢谢!
解决方案 »
- asp.net 4 用路由做URL重写 img图片不显示
- 求论坛代码
- Ajax 服务器怎么json形式数据
- Duwamish7.0cs里的函数问题
- 怎样让imagebutton在新窗体中打开页面?
- 绝对非广告,C#网络教学,完全免费,内详
- 一个关于跨页面传参的问题
- 在DataGrid的模板中每行前面均有一个CheckBox,标题也有一个CheckBox,如何知道哪行的CheckBox被选中?
- 关于控件位置的问题
- VS.Net中在哪里设置aspx,htm文件模板?,我想加入许多我的一些常用代码,新建后就不用那么麻烦了?
- SQL语句问题
- Convert.ToInt32(cmd.ExecuteScalar())提示缺少一个参数,新手请求帮助!
DataKeyNames="WorkerID,SquadID" OnRowCancelingEdit="myGridView_RowCancelingEdit"
OnRowDataBound="myGridView_RowDataBound" OnRowEditing="myGridView_RowEditing"
OnRowUpdating="myGridView_RowUpdating">
<Columns>
<asp:BoundField DataField="WorkerID" HeaderText="ID" ReadOnly="True">
<ItemStyle Width="70px" />
</asp:BoundField>
<asp:TemplateField HeaderText="班组">
<ItemStyle Width="100px" />
<EditItemTemplate>
<asp:DropDownList ID="ddlSquad" runat="server">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblSquadName" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="姓名">
<EditItemTemplate>
<asp:TextBox ID="txtWorkerName" runat="server" MaxLength="20" Text='<%# Bind("WorkerName") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtWorkerName"
Display="Dynamic" ErrorMessage="请填写姓名" ForeColor="White"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label ID="lblWorkerName" runat="server" Text='<%# Bind("WorkerName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True">
<ItemStyle Width="100px" />
</asp:CommandField>
<asp:TemplateField>
<HeaderTemplate>
<input onclick="checkFormAll(this.checked)" type="checkbox">
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server"></asp:CheckBox>
</ItemTemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
</Columns>
</asp:GridView>cs/// <summary>
/// 删除维修人员
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDel_Click(object sender, EventArgs e)
{
//遍历所有的 chkSelect 找出那些项需要删除
string strDel = "";
foreach (GridViewRow gr in this.myGridView.Rows)
{
CheckBox chk = (CheckBox)gr.FindControl("chkSelect");
if (chk.Checked)
{
strDel = strDel + this.myGridView.DataKeys[gr.RowIndex].Value + ",";
}
}
if (strDel != "")
{
QYFY.BLL.Main.Worker bll = new QYFY.BLL.Main.Worker();
//去掉最后的逗号
strDel = strDel.Substring(0, strDel.Length - 1);
//删除用户
bll.Delete(" WorkerID in (" + strDel + ")");
//删除用户角色表中的数据
//QYFY.BLL.Accounts.Accounts_UserRoles bllur = new QYFY.BLL.Accounts.Accounts_UserRoles();
//bllur.Delete(" UserID in (" + strDel + ")");
//重新绑定数据
this.AspNetPager.RecordCount = bll.GetCount(this.lblStrWhere.Text);
this.BindGridView();
}
}