如何点选GRIDVIEW复选框,更新数据库
我想在GRIDVIE控件编辑状态,勾选归还列复选框,勾上表示还了,库存加1,如何实现啊。我取不出该行的字段值,我要按条件更新的。
部分代码:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//if(GridView1.Rows[e.RowIndex].Cells[8].FindControl("CheckBox1"
if (GridView1.Rows[e.RowIndex].Cells[2].Text == "批量入库" && GridView1.Rows[0].Cells[3].Text == "批量入库" && GridView1.Rows[e.RowIndex].Cells[5].Text == "批量入库")
{
SqlDataSource2.UpdateCommand = "UPDATE Tuinfo SET Quantity = Quantity +1 WHERE ZoneName='" + GridView1.Rows[e.RowIndex].Cells[4].Text + "'";
}
if (GridView1.Rows[e.RowIndex].Cells[2].Text == "批量入库" && GridView1.Rows[e.RowIndex].Cells[3].Text == "批量入库")
{
SqlDataSource2.UpdateCommand = "UPDATE Tuinfo SET Quantity = Quantity +1 WHERE ZoneName='" + GridView1.Rows[e.RowIndex].Cells[4].Text + "' and TypeName= '" + GridView1.Rows[e.RowIndex].Cells[5].Text + "'";
}
else
{
SqlDataSource2.UpdateCommand = "UPDATE Tuinfo SET Quantity = Quantity+1 WHERE Tuid ='" + GridView1.Rows[e.RowIndex].Cells[2].Text + "'";
}
SqlDataSource2.Update();
Response.Write("<script>alert('归还图纸成功,数据库更新!')</script>");
}
}
--------------------编程问答-------------------- GridView1.Rows[e.RowIndex].Cells[2].Text 是不是这样取值不对啊 --------------------编程问答-------------------- GridView1.Rows[e.RowIndex].Cells[2].Text 取的只是标题的文本,实际值并未取到 --------------------编程问答-------------------- 在gridview中添加复选框的模版列,updatecommand中做判断是否勾选 --------------------编程问答-------------------- 如何取本行数据字段值,????我就是不知道如何取值 --------------------编程问答-------------------- 各位请帮帮我吧,真的很急,不胜感激! --------------------编程问答-------------------- 有用!!我用上了
补充:.NET技术 , ASP.NET