GridViewRow gridRow
TextBox priceTextBox
int Price, Id
// 遍历GridView中的每一行
for (int i = 0 i < rowsCount i++)
{
// 获行当前行
gridRow = GridView1.Rows[i]
// 通过DATAKEYS来取行没显示出来的ID号
Id = Convert.ToInt32(GridView1.DataKeys[i].Value)
//
priceTextBox = (TextBox)gridRow.FindControl( "TextBox2 ")
// 转换为整形,如果输入的是非法字符Int32.TryParse返回FALSE
if (Int32.TryParse(priceTextBox.Text, out Price))
{
// 调用业务层的方法更新数据
ServerTableBll ServerTableUpdate = new ServerTableBll()
ServerTableUpdate.UpdateServerTable(Id, Price.ToString())
}
首先你要给gridview绑定数据,然后再你的gridview控件的编辑项中添加一些BoundField,设置其属性DataField="id" HeaderText="低保证编号"。其中id是你再数据库中查询出来的字段,只要确保你填写在DataField的字段都来自查询条件就可以了!欢迎分享,转载请注明来源:内存溢出
评论列表(0条)