如何将一个列数据从数据表存储到视图状态 [英] How to store one column data from datatable to a view state
问题描述
我在datatable.i中有多个列需要第二个coulmn值并存储到viewstate或hidden字段中。如何在视图状态下存储一个列数据。
我的代码是
EX -
Hi,
I have multiple column in the datatable.i want second coulmn value and store into viewstate or hidden filed. how to store one column data in a view state.
my code is
EX--
DataTable _dtblanck = GetLatestDataFromGrid();
_dtblanck = obj.madeAddTable(_dtblanck, Session["LoginName"].ToString());
ViewState["dourceofgoods"] = _dtblanck;
这里,我的代码数据表正在保存所有列。我需要在视图状态下只保存一个列数据。
假设这三个couln来自数据表。我只需要将employeeename列数据存储到viewstate或hidden字段中。如何存储一个列数据。
Emplid Employeename 年龄
1 Raj 25
2 ram 35
3 Rasmi 20
Here , i my code datatable is saving with all columns. i need to save only one column data in view state.
suppose this three couln is comming from datatable. i need to store only employeename column data into viewstate or hidden filed. how to store one column data.
Emplid Employeename age
1 Raj 25
2 ram 35
3 Rasmi 20
推荐答案
试试这样..
try like this..
HiddenFieldControlName.Value= dt.Rows[0]["columnName"].ToString();
试试这个
Try this
string[] arrayVariable= _dtblanck.AsEnumerable().Select(s => s.Field<string>("LoginName")).ToArray<string>();
现在你有了数组中列的值将执行您想要执行的任何操作。
Now you have all values of your column in an array do whatever you want to do with it.
这篇关于如何将一个列数据从数据表存储到视图状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!