C#中dataGridView的问题
来源:百度知道 编辑:UC知道 时间:2024/05/15 10:20:49
求form代码
直接给你看代码相信你会晕 我给你一点灵感
datagrideview不是有一个currentrow的属性吗
datagrideview[0,datagrideviewrow.currentrow]就是他的第一个列的数据 剩下的你应该知道怎么做了吧
GridView1.DataKeyNames = new string[] { "主键" };
写在LOAD中.
protected void btnDel_Click(object sender, EventArgs e)
{
for (int i = 0; i < this.GridView1.Rows.Count; i++)
{
if (((CheckBox)this.GridView1.Rows[i].Cells[0].FindControl("chkSelect")).Checked)
{
OA_Business.Employer.Employer epy = new OA_Business.Employer.Employer();
epy.E_ID = int.Parse(GridView1.DataKeys[i].Value.ToString());
epy.E_Del();
}
}
BindEmployer();
}
这是一个用CheckBox选中删除的用于多选的.
很多方式处理这个东西的
dataGridView.selectedItems[0].remove();
包括删除和编辑的全部代码:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;