Solved

Store value retrieved in Session

Posted on 2009-06-29
5
196 Views
Last Modified: 2012-05-07
I am using a Telerik Radgrid ,I have a web form which loads the grid with data by querying against a stored procedure ,the grid is loaded with almost 10 fields but I want to store just the first field (example: UserId) in session and use it on the same page.
Can any one tell me what should I do to retrieve first field from the output(which is dataset)??

Below is my code:
Protected Sub RadViewAllGrid_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles RadViewAllGrid.NeedDataSource
        RadViewAllGrid.DataSource = dataaccess.GetEnrollment
    End Sub
 
Dataacess:
 
Public Function GetEnrollment() As DataTable
            Dim dm As DataManager = Nothing
            Dim ds As DataSet = Nothing
            Dim params As List(Of DataParameter) = Nothing
            Dim errMsg As String = String.Empty
 
            Try
                dm = New DataManager(ConnectionString)
                params = New List(Of DataParameter)
                ds = dm.ExecuteQuery(DataProviderType.SqlClient, EnrollUtility.SP_CHECKUSERIDBYADMIN, ReturnType.DataSetType, CommandType.StoredProcedure, Nothing)
 
 
                Return ds.Tables(0)
 
            Catch ex As Exception
                Throw ex
            Finally
                If Not dm Is Nothing Then dm.Dispose()
            End Try
 
        End Function

Open in new window

0
Comment
Question by:onebite2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:spprivate
ID: 24737709
Userid = ds.Tables[0].Rows[0].ItemArray[0].ToString();
0
 

Author Comment

by:onebite2
ID: 24737711
Where should this be placed according to my code??
0
 

Author Comment

by:onebite2
ID: 24737730
I am sorry the output is a datatable......
To be more clear, for eg my datatable has 3-4 columns but I need to get all the values of column 1(Userid)  and store it in a session variable and pass this session variable to another procedure to update data relevant to that particular ID. How do I do it?
0
 
LVL 15

Expert Comment

by:spprivate
ID: 24738339
Do you want to get all the values in the first column (say 20 records) or you want those records which are selected by the user from UI?
0
 
LVL 15

Accepted Solution

by:
spprivate earned 500 total points
ID: 24738399
What I think you want is that you have this grid in the page where user selects few records and want to do an update on those records.Correct.If that is the case,here is a good article(may be you have seen it).

http://www.telerik.com/help/aspnet-ajax/grdretrieveprimarykeyfieldvaluesforitems.html

In the given example where you use response.write,instead of that keep adding the values as a session string with comma separator.

Say the user click record 1,4,7 then the session variable would be
Session["idselected"]=Session["idselected"].tostring()+",",e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ID")
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question