如何在Windows应用程序中更新dataGridview控件的列。 [英] How to update columns of dataGridview control in Windows Application.

查看:59
本文介绍了如何在Windows应用程序中更新dataGridview控件的列。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#2.0和SQL Server 2005开发Windows窗体应用程序。在我的应用程序中,我通过单击数据库中的btnLoadData按钮将数据检索到dataGridview控件中。用于检索数据的代码示例: -

private void btnLoadData_Click(object sender,EventArgs e)

{

string s1 =select * from Sales_Details ;

SqlConnection cn = new SqlConnection(Class1.cs);

cn.Open();

SqlDataAdapter da = new SqlDataAdapter(s1 ,cn);

DataSet ds = new DataSet();

da.Fill(ds);

dataGridView1.DataSource = ds.Tables [0];

cn.Close();

}

我想通过点击列来更新或编辑该dataGridview的列并使用相同的ID将其保存回数据库。但我不知道该怎么做,请有人帮帮我。

I m developing a Windows Form Application by using C# 2.0 and SQL Server 2005. In my application, I retrieve data by clicking a btnLoadData button from the database into a dataGridview contrl. Code sample to retrieve data:-
private void btnLoadData_Click(object sender, EventArgs e)
{
string s1 = "select * from Sales_Details";
SqlConnection cn = new SqlConnection(Class1.cs);
cn.Open();
SqlDataAdapter da = new SqlDataAdapter(s1, cn);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
cn.Close();
}
I want to update or edit a column of that dataGridview by clicking the column and save it back to the database by using the same ID. But I don't know how to do this, please someone help me.

推荐答案

这些肯定对你有帮助..

在DataGridView中使用分页添加,编辑和删除 [< a href =http://www.codeproject.com/Articles/17318/Add-Edit-and-Delete-in shellsGridView-with-Pagingtarget =_ blanktitle =New Window> ^ ]

数据库更新 - 来自datagridview / [ ^ ]

插入-删除更新管理记录 - 进入 - 数据库使用-datagridview的功能于视觉-C [<啊REF =http://social.msdn.microsoft.com/Forums/en-US/8db841fc-ffa7-4519-b6f5-d054c7190948/insert-deleting-updating-records-into-database-using-datagridview-in-visual -ctarget =_ blanktitle =New Window> ^ ]
These will definitely help you..
Add, Edit, and Delete in DataGridView with Paging[^]
Database-updation-from-datagridview/[^]
Insert-deleting-updating-records-into-database-using-datagridview-in-visual-c[^]


在此尝试:自动保存DataGridView行到SQL Server数据库 [ ^ ]



这不是一篇新文章,但它涵盖了您正在使用的技术:.NET 2和SQL 2005
Try here: Auto Saving DataGridView Rows to a SQL Server Database[^]

It's not a new article, but it covers the technology you are using: .NET 2 and SQL 2005


这篇关于如何在Windows应用程序中更新dataGridview控件的列。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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