如何使用c#在Datagridview中动态绑定两个文本框值? [英] How to Bind the two textbox Values Dynamically in Datagridview using c#?

查看:88
本文介绍了如何使用c#在Datagridview中动态绑定两个文本框值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

海,

如何使用c#在Datagridview中动态绑定两个文本框值?

Hai,

How to Bind the two textbox Values Dynamically in Datagridview using c#?

推荐答案

检查以下内容:

http://msdn.microsoft.com/en-us/library/y0wfd4yz.aspx [ ^ ]

http://www.akadia.com/services/dotnet_databinding.html [
Check these out:

http://msdn.microsoft.com/en-us/library/y0wfd4yz.aspx[^]

http://www.akadia.com/services/dotnet_databinding.html[^]

hope it helps :)


您可以通过创建DataSet或DataView将任何控件绑定到数据库. 首先创建New DataView.
You can bind any control to the DataBase by creating DataSets or DataView.
First create New DataView.
public void CreateDataView()
       {
       OleDbDataAdapter objda = new OleDbDataAdapter();
       objda.SelectCommand = new OleDbCommand();
       Conn.Open(); //Openning DataBase Connection
       objda.SelectCommand.CommandText = "Select * FROM TableName";
       objda.Fill(objdataset, "TableName");
       dv = new DataView(objdataset.Tables("TableName"));
       }


在Form_Load事件上调用CreateDataView.
然后将您的TextBox与DataView绑定


Call CreateDataView on Form_Load Event.
Then bind your TextBox with DataView

this.TextBox1.DataBindings.Clear();
this.TextBox1.DataBindings.Add("Text", dv, "TableFieldName");



-MKB:)



-MKB :)


这篇关于如何使用c#在Datagridview中动态绑定两个文本框值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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