Solved

Store value retrieved in Session

Posted on 2009-06-29
5
194 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
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Where did System.Data.Objects go? 2 28
tutorial for ebay api 3 35
Save ms data to server side. 19 46
Calculate number of nights between two dates 5 25
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

810 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