473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

How to get from loop Session on data reader?

Hi I am trying to send session on Loop and trying get . Can anyone please help me to do it?

SessionSend.aspx.cs
---------------------------
Expand|Select|Wrap|Line Numbers
  1. cmd.CommandText = "SELECT * FROM NewsEvents ORDER BY PostedDate DESC";
  2.  while (dr.Read())
  3.                {
  4.                    Session["id"] = dr["NewsId"].ToString();
  5.  
  6.                 Label1.Text += "<a href=DetailsView.aspx>Click Here for Details</a>";
  7. }

SessionGet.aspx.cs
---------------------------
Expand|Select|Wrap|Line Numbers
  1. cmd.CommandText="SELECT * FROM NewsEvents WHERE NewsId=@Sessionid";
  2. cmd.Parameters.AddWithValue("Sessionid", Session["id"].ToString());

In above code, I just only get same SessionId on every news headings, how do I get next row session id?
Nov 26 '10 #1
2 1996
Frinavale
9,735 Expert Mod 8TB
Store an array of the heading in session...or store the whole data table into session if you want to.

Right now you are overwriting the value at Session["id"] each loop iteration.

-Frinny
Dec 6 '10 #2
Thanks for your response,

Can you show me please how can I make array in this situation?

I would appreciate ur help
Dec 8 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
2
by: ensnare | last post by:
Hi all, I'm using a database session handler and am looking to loop through data residing in the sessions table to make a 'Users online' array. I've found that using urldecode on the data...
3
by: Marcus | last post by:
Hello all, I have written numerous functions that check all user entered data on my site via POST and GET. My question is this: once my data checks out as being valid, I sometimes store it in...
1
by: Mike P | last post by:
I'm using 1 connection to open 3 separate data readers to read data into 3 data grids. However, when I try to use the 2nd reader it says that the first reader must be closed. So I use Close() to...
1
by: mhnazly | last post by:
i'm trying to read data from SQL Server database using data reader and assigned it to a label in my asp.net web application. but when the button is clicked, nothing appears. please help, thanks. ...
4
by: Ram | last post by:
I am using ADO.Net data reader to retrieve data from main frame. I am getting timestamp which is 26 (yyyy-mm-dd hh- mm-ss.123456) bytes as sqltimestamp data type. I am using data reader to...
2
by: Anuradha | last post by:
Dear Experts How can I count how many records load to the Data Reader And if I run while.dataReader.read() loop. will it automatically move to the next record and loop pls help me
6
by: Jim Heavey | last post by:
I am new to SqlServer, have been using Oracle in a prior life. I have written a very simple stored procedure in SQL Server and it (the query) looks like the following... Select AD_ID,...
3
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, how do you resolve this problem? i have a public procedure in my DataAccessLayer that gets a SqlDataReader how do i close the reader from inside the DataAccessLayer if I'm returning...
3
by: charvi | last post by:
i hae a ole data reader which contains records extracted from Query.how can i check for end of file in data reader.and i want to know the number of records present in data reader thanks in advance
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.