如何使用按钮单击事件更新数据网格选定记录数据库 [英] How Do I Update Database With Datagrid Selected Record Using Button Click Event

查看:68
本文介绍了如何使用按钮单击事件更新数据网格选定记录数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,



我正在尝试进行数据库更新,我希望能够根据复选框值从数据网格中检索记录并更新使用按钮点击事件的数据库。



i试过这个:



Hello Everyone,

I am trying to carryout database update, i want to be able to retrieve record from datagrid based on checkbox value(s) and update the database with it using button click event.

i have tried this:

if ( e.RowIndex < 0 || e.ColumnIndex < 0 )
            {
                return;
            }

            string deviceType = "", deviceName = "", modelNumber = "", macAddress = "";
            string  isActive, isInUse;
            int deviceId=0;
            deviceId = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[0].Value + "");
           
                   
                    deviceType = dataGridView1.Rows[e.RowIndex].Cells[1].Value + "";
                    deviceName = dataGridView1.Rows[e.RowIndex].Cells[2].Value + "";
                    modelNumber = dataGridView1.Rows[e.RowIndex].Cells[3].Value + "";
                    macAddress = dataGridView1.Rows[e.RowIndex].Cells[4].Value + "";
                    isActive = dataGridView1.Rows[e.RowIndex].Cells[5].Value + "";
                    isInUse = dataGridView1.Rows[e.RowIndex].Cells[6].Value + "";





这似乎只适用于单击事件,请问如何在按钮点击事件中实现此目的



This seem to work only on a cellclick event, please how do i achieve this in a button click event

推荐答案

亲爱的mfon彼得,



我建议你仔细阅读这篇文章会帮助你。





http://aspsnippets.com/Articles/Bulk-Edit-Update-Multiple-Rows-in-ASPNet-GridView-using-CheckBoxes .aspx [ ^ ]







编辑Ind ASP.NET中的ividual GridView单元格 [ ^ ]





http://aspadvice.com/blogs/azamsharp/archive/2006/12/18/GridView-Update-All-Rows-At-Once.aspx [ ^ ]







足以解决您的问题,如果没有,请使用deailed代码恢复。



谢谢。

Manoj Kalla
Dear mfon peter,

I suggesting you go through this article wil help you.


http://aspsnippets.com/Articles/Bulk-Edit-Update-Multiple-Rows-in-ASPNet-GridView-using-CheckBoxes.aspx[^]



Edit Individual GridView Cells in ASP.NET[^]


http://aspadvice.com/blogs/azamsharp/archive/2006/12/18/GridView-Update-All-Rows-At-Once.aspx[^]



Sufficient to solve your problem, If not, please, revert back with deailed codes.

Thank You.
Manoj Kalla


这篇关于如何使用按钮单击事件更新数据网格选定记录数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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