• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

Session Dataset Value Get?

I need to get a single value from a session dataset, but so far no luck.

I know data exists because I can merge this dataset with another dataset and save it to a database.

Here are my attempt:

DataSet ds = (DataSet)Session["mydataset"];

       string Product = Session["Product"].ToString();


0
kvnsdr
Asked:
kvnsdr
  • 3
  • 2
1 Solution
 
brdrokCommented:
Perhaps only a typo???

string Product = ds["Product"].ToString();
0
 
kvnsdrAuthor Commented:
That's closer, but now I recieve an error:

Cannot apply indexing with [] to an expression of type 'System.Data.DataSet'

I've also tried:  string Product = ds.Tables[0].Columns[5].ToString();

then for the result I get the column name:  col_Product

I know the data is there, but...
0
 
brdrokCommented:
i believe you'll have to specify the row number...try the following:

string Product = ds.Tables[0].Rows[0][5].ToString();

where the [0] <= row number
where the [5] <= column number
0
 
brdrokCommented:
do you mind if i ask why the grade of "B"?
0
 
kvnsdrAuthor Commented:
Sorry, I goofed........
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now