目前datagridview首列是复选框,我想根据选中的时候删除数据,怎么实现,
是否被选中复选框就行
是否被选中复选框就行
解决方案 »
- WIN7怎么对webservice单步调试
- 关于C#的List<T>的remove的问题
- vb 调用c#写的dll
- 怎样在没有安装office的机器上提取word文档中的文本
- 代码出错,大家帮忙看看啊!!!!急!!!!
- 怎样根据DataReader读出来的一列条件,填写一个DataTable
- string OleDbconnString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = D:\\学
- 聘.net程序开发人员(北京)
- error CS0006: 未能找到元数据文件“System.DirectoryServices.dll”怎么回事儿?
- 如何实现按纽的互锁?
- 数据库 编号重复问题!
- 删除按钮,复选框的问题
我用伪语言给你写一哈哈
你之前的sql-db 连接语句和 sqlcommand的设置我就不写了哈。
在button里添加如下代码:
if(checkbox.checked==true)
{
string strsql=checkbox.text.tostring();
..... (执行sql语句)
} 希望对你有用!!
{
int id = (int)this.dataGridView1.Rows[i].Cells["num"].Value;
int val = AssertManager.DelAssert(id);
if (val > 0)
{ }
else
{
MessageBox.Show("no");
} }怎样循环复选框,给代码看看,谢谢大家
function setCheck(obj)
{
var comxid=obj;
if(document.getElementById(comxid).checked==true)
{
document.getElementById("check_ids").value = document.getElementById("check_ids").value+obj+",";
}
else
{
document.getElementById("check_ids").value = document.getElementById("check_ids").value.replace(obj+",",'');
}
} <input type="checkbox" style="width:20px;height:20px;" id="ads" name="ads" value='阿萨德' onclick="setCheck(this.value);"/>
<input type="hidden" id="check_ids" name="check_ids"/>
String value= Request.Form["check_ids"].TrimEnd(',');
http://blog.csdn.net/wyaspnet/archive/2008/10/10/3049901.aspx
function setCheck(obj,value)
{
var comxid=obj;
if(document.getElementById(comxid).checked==true)
{
document.getElementById("check_ids").value = document.getElementById("check_ids").value+value+",";
}
else
{
document.getElementById("check_ids").value = document.getElementById("check_ids").value.replace(value+",",'');
}
}
<input type="checkbox" style="width:20px;height:20px;" id="ads" name="ads" value='阿萨德' onclick="setCheck(this.name,this.value);"/>
<input type="hidden" id="check_ids" name="check_ids"/>
{
CheckBox cb = (CheckBox)Gridno.Rows[gvr.RowIndex].FindControl("CkItemno");//chItemno 是复选框的Id
if (cb.Checked)
{
if (TempPersonId.Trim() == "")
TempPersonId = Gridno.DataKeys[gvr.RowIndex].Value.ToString();
else
{
TempPersonId += "','" + Gridno.DataKeys[gvr.RowIndex].Value.ToString();
}
}
}