从gridview将数据存储在数据库中. [英] Storing data in database from the gridview.

查看:61
本文介绍了从gridview将数据存储在数据库中.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我有一个gridview,在该gridview中有一个复选框,一个数据绑定项,文本框,下拉列表,单选按钮.

如果选中此复选框,则应通过按提交按钮将包含数据绑定项目,文本框和下拉列表所选项目中数据的网格视图的特定行数据存储到数据库中.

请回复..

干杯JAGADiSH ...

Hi friends,

I have a gridview, in that gridview there is checkbox, one databound item, textbox, dropdownlist, radio button.

when checkbox checked then that particular row data of the gridview which containing the datas in databound item, textbox, and dropdownlist selected item should get store to database by pressing submit button.

please reply..

Cheers JAGADiSH...

推荐答案

我假设您可以通过选中多个复选框来更新多个记录.
在提交"按钮上,单击事件进行以下代码.

I assume that you can update more than one record by selecting multiple check box.

On Submit buttons click event make following code.

for (int i = 0; i < grdDisplayAll.Rows.Count; i++)
{
  string id;
  //Here it is assume that your first cell contains CheckBox
  if (Convert.ToBoolean(grdDisplayAll.Rows[i].Cells[0].Value) == true)
  {
       //Make Code here to update record.
       id = grdDisplayAll.Rows[i].Cells["Id"].Value.ToString();
       //You may Use ColunIdex instead of ColumnId (i.e Here "Id")
  }
}




如果对您有帮助,请标记为 答案/解决方案 . :-O:)




Mark as Answer/Solution if it is helpful to you. :-O :)


有两种情况

1.如果您的网格是可编辑的,则意味着提供内联编辑,然后要将网格保存到数据库,请参考 ^ ]链接.

2.如果仅一次生成了网格,则不再提供任何编辑,请参考 [ ^ ]链接.



HTH
There are two scenarios that

1. if your grid is editable, means provides inline editing and then want to save grid to database refer this[^] link.

2. if your grid is just generated one time, no more editing has been provided then refer this[^] link.



HTH


这篇关于从gridview将数据存储在数据库中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆