Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataBinding between a DataGridView and a TextBox
 

DataBinding between a DataGridView and a TextBox

Hey guys,

I have a DataGridView that is bound to a DataTable. The DataTable includes3 columns named StudentID, Nameand Comment. Because the Comment may include large amount of formatted text, I'm displaying the contents of this column in a separate control, which is a TextBox. So, the DataGridView shows onlythe ID and theName of each student. When you select a row in the DataGridView, the Comment associated with that student is displayed in the TextBox. I want the user to be able to edit the TextBox and the DataSet be updated accordingly.

What's the best way to implement this?

Hope to hear from you soon.

Cheers,

Mosh

romance82m  Friday, September 19, 2008 6:48 AM

Hi Romance82m,

Iwas having same situation.

I did one thing,

I was binding DataGridView with DataSet , and textbox with datamember of that dataset.

So after that, if you edit that value in TextBox it will also reflect in DataSource also.

Actually , i was not using DataSet, but i was Using Collection and CurrencyManager for this whole thing.

So, Both(DataSet and Collection With CurrencyManager) methods are almost same.

So, your problem might solve by using this..

If i am wrong , let me know. If you found another solution then also let me know.

Thanks in Advance

Thank You

Best Regards

Utkarsh Gajjar

Utkarsh  Friday, September 19, 2008 2:26 PM

Hi Romance82m,

Iwas having same situation.

I did one thing,

I was binding DataGridView with DataSet , and textbox with datamember of that dataset.

So after that, if you edit that value in TextBox it will also reflect in DataSource also.

Actually , i was not using DataSet, but i was Using Collection and CurrencyManager for this whole thing.

So, Both(DataSet and Collection With CurrencyManager) methods are almost same.

So, your problem might solve by using this..

If i am wrong , let me know. If you found another solution then also let me know.

Thanks in Advance

Thank You

Best Regards

Utkarsh Gajjar

Utkarsh  Friday, September 19, 2008 2:26 PM
Hi,

I have a data grid view that is showing a table from access. It has 4 colums, (1) Name (2) Phone Number (3) Adress (4) Status. Once my grid view is showing the required records, I want only the Phone Number column to be displayed in a ListBoxView. Can you please help with this?

Thanks
Ammar Moughis
Ammarm  Saturday, February 28, 2009 11:26 PM

You can use google to search for other answers

Custom Search

More Threads

• DatagridvewComboBox - databound lists per row
• replace data in MS Access table with datagridview data
• What will happen after the update of the DataGridView containing data from the different tables?
• [C#]datagridview copy/paste entire rows
• CellBeginEdit event raised on DataGridView control refresh
• Help: DGV Combobox settings
• Getting Dataset information behind Datagrid Row
• DataGridViewCheckBoxColumn with Text Information
• Having probs with DataTable.ChildRelations --- keep getting a exception
• Another "System.Argument.Exception: DataGridViewComboBoxCell value is not valid" thread