开发者

updating dataset c# asp

开发者 https://www.devze.com 2022-12-13 17:47 出处:网络
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

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开发者_Python百科 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


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")
0

精彩评论

暂无评论...
验证码 换一张
取 消