404ram
404ram

Reputation: 33

updating dataset c# asp

I have written some logic in C#. Now I need to update it to the already created Dataset. The Dataset is containing a Table PackageTable. It has two fields, PackageId, and PackagePrice Now, I want to search the table for certain Packageid, say 'P1' and update the PackagePrice with a new value , say '100'.

Please tell me how to do it with C#. Please also note that I am not updating it using a textbox or gridview etc. Thanks in advance

Upvotes: 0

Views: 232

Answers (1)

Adriaan Stander
Adriaan Stander

Reputation: 166606

You can try this

dt.Select("PackageId = 1")[0]["PackagePrice"] = 2;

dt is your data table, select the rows from it, then set the field value to what you require.

From comments, small example

Dim dt As New DataTable
dt.Columns.Add("t")
Dim r As DataRow
r = dt.NewRow
r("t") = "aa"
dt.Rows.Add(r)

DataGridView1.DataSource = dt

Dim d As DataTable
d = DataGridView1.DataSource
TextBox1.Text = d.Rows(0)("t")

Upvotes: 1

Related Questions