Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends ,


I have data in view state (view state name is "Sample")
view state contains columns Id,Name

DataTable _Sample= new DataTable();
_Sample= MagazinesDataSource.Load(_magazinesEntity);
ViewState["Sample"] = _Sample;

this viewstate consists of 100 records



I need "Id" from view state when i pass the "Name" to view state

how can i get the data


thank you
Posted
Updated 11-Jun-13 21:41pm
v4
Comments
Jameel VM 11-Jun-13 11:41am    
can you post the code that you set the values Id and Name in to viewstate
ZurdoDev 11-Jun-13 12:45pm    
Please post your relevant code because this does not make much sense.
Nandakishore G N 12-Jun-13 2:08am    
paste the code, what have you done till now? We Can help you in fixing it.
siva575 12-Jun-13 2:43am    
DataTable _sample= new DataTable();
_sample= MagazinesDataSource.Load(_magazinesEntity);
ViewState["sample"] = _sample;


i get all record from database to this view state , i will pass name to this and get id related to that name
Nandakishore G N 12-Jun-13 4:20am    
refer this http://www.codeproject.com/Tips/529860/How-to-Copy-Data-from-SqlDataSource-to-Datatable-a
load the data to datatable and refer above link use select() of datatable and filter or get the values

1 solution

Not able to understand what exactly your requirement .. but still try this code.it may help you.


XML
ViewState["data"] = "12,Rajesh";
       string name = ViewState["data"].ToString();
       string[] id = name.Split(',');

       Response.Write("Id is : " + id[0].ToString());
       Response.Write("<br>Name is : " + id[1].ToString());
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900