Solved

Store value retrieved in Session

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb.net - How to check if current user is an administrator? 6 34
Server Error 11 47
IIS issues - Convert to Application - APS.NET v4.0 3 21
Variable Event ? 3 22
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now