网格视图行一次 [英] grid view rows at once

查看:136
本文介绍了网格视图行一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有每行都有一个复选框,以便为所有那些被选中,我想在数据库中保存我怎么能做到这一点鱼卵网格视图?

i have a grid view where each row has a check box so for all those roes which are checked i want to save in data base how can i achieve this?

我需要为每个数据行执行单独的数据库操作还是可以一次发送所有的行数据库
我是否需要写一些特殊的查询?

do i need to perform separate database operation for each datarow or i can send all row to database at once do i need to write some special query?

或者我可以有一些临时表,然后我可以一次插入所有请赐教在此

or i can have some temporary table then i can insert all at once please enlighten me on this

推荐答案

您可以使用for语句或foreach语句来做到这一点。

You can use a for statement or a foreach statement to do this.

通过每个行的迭代

foreach (DataGridViewRow dr in myDataGridView.Rows)
{
      if(dr.Cells[0].Value != null) //Cells[0] Because in cell 0th cell we have added checkbox
      {
          //Do something with the row
      }     

}

从的http://www.dotnetspark.com/kb/151-add-checkbox-inside-datagridview-windows.aspx

但是,如果我们谈论超过100或200行,你应该使用一个机制svanryckeghem提到或BULK INSERT。

But if we are talking about more than 100 or 200 rows, you should use a mechanism svanryckeghem has mentioned or a BULK INSERT.

这篇关于网格视图行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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