请问,什么方法才能遍历DataGrid中的每一行的某个控件? for(int i=0;i<this.dg.Items.Count;i++){CheckBox chkbox=(CheckBox)(this.dg.Items[i].FindControl("boardid"));if(chkbox.Checked){}} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void delButton_Click(object sender, System.EventArgs e) { System.Web.UI.WebControls.CheckBox checkBox; for( int i = 0; i < DataGrid1.Items.Count; i ++ ) { //查找CheckBox控件 checkBox = (CheckBox)DataGrid1.Items[i].FindControl("CheckBox1"); if(checkBox!=null && checkBox.Checked) { checkBoxID = DataGrid1.Items[i].Cells[1].Text; CB_ItemName = DataGrid1.Items[i].Cells[2].Text; delDataGrid(); } } //重新绑定DataGrid BindData(); } private void delDataGrid() { SqlConnection sqlConnection1 = new SqlConnection( material.source ); sqlConnection1.Open();//打开数据库连接 //Sql删除语句 string strDel = "DELETE FROM AcceptMaterialTwo WHERE ItemNum='"+checkBoxID+"'"; System.Data.SqlClient.SqlCommand sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand( strDel, sqlConnection1 ); sqlDeleteCommand1.ExecuteNonQuery(); sqlConnection1.Close(); // 关闭数据库连接 } 求救,另一个页面里的信息如何在当前页面显现 100问一个小问题:如何修改datarow的值? 问个表单提交的问题 简简单单 问个div的问题.高手来帮忙. 请各位大侠出手帮忙!!奇怪的问题,着急着呢!!! 请问:怎样处理错误的Request["TopicID"]参数? 事件通知!麻烦各位! 与VB中 if pName is Nothing 等效的C#语句是什么 一个javascript的脚本问题 急问:如何把[绑定]到textbox的值修改以后,更新回数据库 !在线散分! ~~ 如何在vs.net中调试js脚本 初学水晶报表,一个小问题请教大家
{
System.Web.UI.WebControls.CheckBox checkBox;
for( int i = 0; i < DataGrid1.Items.Count; i ++ )
{
//查找CheckBox控件
checkBox = (CheckBox)DataGrid1.Items[i].FindControl("CheckBox1"); if(checkBox!=null && checkBox.Checked)
{
checkBoxID = DataGrid1.Items[i].Cells[1].Text; CB_ItemName = DataGrid1.Items[i].Cells[2].Text;
delDataGrid();
}
}
//重新绑定DataGrid
BindData();
}
private void delDataGrid()
{ SqlConnection sqlConnection1 = new SqlConnection( material.source ); sqlConnection1.Open();//打开数据库连接
//Sql删除语句
string strDel = "DELETE FROM AcceptMaterialTwo WHERE ItemNum='"+checkBoxID+"'";
System.Data.SqlClient.SqlCommand sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand( strDel, sqlConnection1 );
sqlDeleteCommand1.ExecuteNonQuery();
sqlConnection1.Close(); // 关闭数据库连接
}