Winform C# Update DataGridView on DataTable Cell value changed

Vimesh Shah

I have DataGridView and DataTable, DataTable is assigned as a datasource in DataGridView.

When I change some value in DataTable it is not update on the view.

So How can i achive this

I have tried following things

  1. BindingSource
  2. Refresh()

Demo Code

DataGridView datagrid = new DataGridView();
DataTable dt = new DataTable();

dt.Columns.Add("No");
dt.Columns.Add("Name");

for (int i = 1; i <= 10; i++)
{
     DataRow row = dt.NewRow();
     row[0] = i;
     row[1] = "ABC";
     dt.Rows.Add(row);
}

datagrid.DataSource = dt;

Here my above code

When i change some value in DataTable it is not reflect in DataGridView

dt.Rows[0][1] = "XYZ";

So Please help me....

thewisegod

I am able to do this, which works:

private DataTable _dt = new DataTable();  

private void Form1_Load(object sender, EventArgs e)
{

    _dt.Columns.Add("LongText");
    DataRow dr = _dt.NewRow();
    dr[0] = "One";
    _dt.Rows.Add(dr);
    dr = _dt.NewRow();
    dr[0] = "Two";
    _dt.Rows.Add(dr);
    dr = _dt.NewRow();
    dr[0] = "Three";
    _dt.Rows.Add(dr);
    dataGridView1.DataSource = _dt;
}

private void button1_Click(object sender, EventArgs e)
{
    _dt.Rows[0][0] = "daddy";
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Update Jquery Datatable Cell Value

From Dev

Select a column value of DataGridView in c# winform

From Dev

Select a column value of DataGridView in c# winform

From Dev

How to get Value of specific cell of datagridview in Winform application

From Dev

How to get Value of specific cell of datagridview in Winform application

From Dev

C# DataGridView Event to Catch When Cell (ReadOnly) Value has been changed by user

From Dev

C# DataGridView Event to Catch When Cell (ReadOnly) Value has been changed by user

From Dev

C# Winform (Entity Framework) - cast databound DataGridView or BindingSource to DataTable

From Dev

DataGridView update Cell Value while typing

From Dev

c# winform datagridview cell click to TabControl Page

From Dev

DataGridView Event to Catch When Cell Value Has Been Changed by User

From Dev

Changed datagridview cell backgroung color

From Dev

Restoring Previous cell value in c# datagridview

From Dev

C# retrieve cell value from datagridview

From Dev

C# winform set value and name of combobox item from DataTable

From Dev

DataGridView Cell Value Changing

From Dev

DataGridView Cell Value Changing

From Dev

Hiding a value in a datagridview cell

From Dev

How can I detect the cell value changed of a specific datagridview column? - VB.NET

From Dev

C# DataGridView: How to change a single cell value

From Dev

C#: How do I get the value of an unbound DataGridView cell?

From Dev

focus in a cell value of DataGridView C# windows forms on adding a row

From Dev

VB.NET Update Issue in DataGridView Cell for TimePicker: Enter Key Does not Update Displayed Value

From Dev

VB.NET Update Issue in DataGridView Cell for TimePicker: Enter Key Does not Update Displayed Value

From Dev

update DataGridView column value

From Dev

Google DataTable - Update cell and display

From Dev

How to convert DataTable Cell Value to Object Array in C#

From Dev

Change DataGridView Cell Value Programmatically

From Dev

Convert a DataGridView Cell Value into a DateTime

Related Related

  1. 1

    Update Jquery Datatable Cell Value

  2. 2

    Select a column value of DataGridView in c# winform

  3. 3

    Select a column value of DataGridView in c# winform

  4. 4

    How to get Value of specific cell of datagridview in Winform application

  5. 5

    How to get Value of specific cell of datagridview in Winform application

  6. 6

    C# DataGridView Event to Catch When Cell (ReadOnly) Value has been changed by user

  7. 7

    C# DataGridView Event to Catch When Cell (ReadOnly) Value has been changed by user

  8. 8

    C# Winform (Entity Framework) - cast databound DataGridView or BindingSource to DataTable

  9. 9

    DataGridView update Cell Value while typing

  10. 10

    c# winform datagridview cell click to TabControl Page

  11. 11

    DataGridView Event to Catch When Cell Value Has Been Changed by User

  12. 12

    Changed datagridview cell backgroung color

  13. 13

    Restoring Previous cell value in c# datagridview

  14. 14

    C# retrieve cell value from datagridview

  15. 15

    C# winform set value and name of combobox item from DataTable

  16. 16

    DataGridView Cell Value Changing

  17. 17

    DataGridView Cell Value Changing

  18. 18

    Hiding a value in a datagridview cell

  19. 19

    How can I detect the cell value changed of a specific datagridview column? - VB.NET

  20. 20

    C# DataGridView: How to change a single cell value

  21. 21

    C#: How do I get the value of an unbound DataGridView cell?

  22. 22

    focus in a cell value of DataGridView C# windows forms on adding a row

  23. 23

    VB.NET Update Issue in DataGridView Cell for TimePicker: Enter Key Does not Update Displayed Value

  24. 24

    VB.NET Update Issue in DataGridView Cell for TimePicker: Enter Key Does not Update Displayed Value

  25. 25

    update DataGridView column value

  26. 26

    Google DataTable - Update cell and display

  27. 27

    How to convert DataTable Cell Value to Object Array in C#

  28. 28

    Change DataGridView Cell Value Programmatically

  29. 29

    Convert a DataGridView Cell Value into a DateTime

HotTag

Archive