Solved

Store value retrieved in Session

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

688 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