Solved

Store value retrieved in Session

Posted on 2009-06-29
5
192 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
Comment Utility
Userid = ds.Tables[0].Rows[0].ItemArray[0].ToString();
0
 

Author Comment

by:onebite2
Comment Utility
Where should this be placed according to my code??
0
 

Author Comment

by:onebite2
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

14 Experts available now in Live!

Get 1:1 Help Now