在memmory数据中更新 [英] update in memmory data

查看:58
本文介绍了在memmory数据中更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我有一个由内存数据表填充的gridview。当用户选择gridview中的行时,我希望用户能够编辑不在数据库中的内存表中的数据。



ID,name,姓氏

1,Divan,Du piesanie //这将是我要将名字更改为Abel的选定行

2,bill,benington



如何进行更新。

解决方案

也许这些链接可以帮助你 -

http://howtouseasp.blogspot.in/2010/10/ how-to-create-temporary-table-in-aspnet.html [ ^ ]

http://www.c-sharpcorner.com/Forums/Thread/94594/ [ ^ ]


int index = GridView2.SelectedIndex;



System.Data.DataTable dt = new System.Data.DataTable();

dt =(System.Data.DataTable)ViewState [SelectedRecords];





DataRow dr = dt .Rows [index];



dr [F1] = DropDownTitle.SelectedValue; //是数据表中的列名

dr [F2] = txtName.Text;

dr [F3] = txtSurname.Text;

dr [F4] = txtCellNum.Text;

dr [F5] = txtRef.Text;

dr [F6] = txtDob.Text;



ViewState [SelectedRecords] = dt;





GridView2.DataSource = dt;

GridView2.DataBind();

Hi all I have a gridview that gets populated by a in memmory data table. when the user selects the row in the gridview i want the user to be able to edit the data in the in memmory table not in the database.

ID,name ,surname
1 ,Divan,Du piesanie//this would be the selected row I want to change the name to Abel
2 ,bill ,benington

How do I do the update.

解决方案

Perhaps these links will help you out -
http://howtouseasp.blogspot.in/2010/10/how-to-create-temporary-table-in-aspnet.html[^]
http://www.c-sharpcorner.com/Forums/Thread/94594/[^]


int index = GridView2.SelectedIndex;

System.Data.DataTable dt = new System.Data.DataTable();
dt = (System.Data.DataTable)ViewState["SelectedRecords"];


DataRow dr = dt.Rows[index];

dr["F1"] = DropDownTitle.SelectedValue ;// is the column name in the datatable
dr["F2"] = txtName.Text;
dr["F3"] = txtSurname.Text ;
dr["F4"] = txtCellNum.Text;
dr["F5"] = txtRef.Text;
dr["F6"] = txtDob.Text;

ViewState["SelectedRecords"] = dt;


GridView2.DataSource = dt;
GridView2.DataBind();


这篇关于在memmory数据中更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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