datagridview中用的checkbox列当点击checkbox时获取该行第二列的值并累加字符串得到最终的strSqlID,当如果要取消其中选到的某个该怎样从strSqlID 中去掉这个值呢
if (dgvPOrder.CurrentCell.ColumnIndex == 0)
{
orderID = dgvPOrder.CurrentRow.Cells[1].Value.ToString();
strSqlID = strSqlID + "DocNum=" + "'" + orderID + "'" + " or ";
}
if (dgvPOrder.CurrentCell.ColumnIndex == 0)
{
orderID = dgvPOrder.CurrentRow.Cells[1].Value.ToString();
strSqlID = strSqlID + "DocNum=" + "'" + orderID + "'" + " or ";
}
我看你是要拿这东西当where条件用的
调用的时候在累加吧
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
string strInfo = "您选择的员工编号为:";
//循环遍历GridView1中的所有模板列CheckBox控件
for (int rowindex = 0; rowindex < this.GridView1.Rows.Count; rowindex++)
{
//取出每一行的CheckBox控件,并判断是否被选中
if (((CheckBox)this.GridView1.Rows[rowindex].Cells[0].FindControl("选中")).Checked == true)
{
strInfo = strInfo + this.GridView1.DataKeys[rowindex].Value + ";";
}
}
Label1.Text = strInfo;
}
}