473,386 Members | 1,766 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,386 software developers and data experts.

Assign value from datagrid to a session variable

This works fine:
<% Session["Session_player"]=1; %>
but this:
<% Session["Session_player"]=%> <%# DataBinder.Eval(Container.DataItem,
"playerID") %> <%; %>

do not work.

The playerID contains the value 1, so the values in both examples are the
same.
What do you suggest - where should i look ??
Nov 18 '05 #1
3 4094
Hi Jesper:

Keep the entire statement inside the data binding delimeters:

<%# Session["Session_player"] =
DataBinder.Eval(Container.DataItem, "playerID") %>

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sat, 23 Oct 2004 21:14:01 +0200, "Jesper Pedersen"
<jb*@microtus.dk> wrote:
This works fine:
<% Session["Session_player"]=1; %>
but this:
<% Session["Session_player"]=%> <%# DataBinder.Eval(Container.DataItem,
"playerID") %> <%; %>

do not work.

The playerID contains the value 1, so the values in both examples are the
same.
What do you suggest - where should i look ??


Nov 18 '05 #2
Hi Scott !

Great...thanks.....now is works......nearly as planned.......

Now, I got to figure out why Session["Session_player"] contains the last
value in the database rather than the current value.

It is assigned in:
<ItemTemplate>
<a href="player_details.aspx?spillerID=<%#
DataBinder.Eval(Container.DataItem, "PlayerID") %>"
target="_parent"> <%# DataBinder.Eval(Container.DataItem,
"playerFirstName") %>
<%#
DataBinder.Eval(Container.DataItem, "playerLastName") %> </a>
<%# Session["Session_player"] =
DataBinder.Eval(Container.DataItem, "playerID") %>
</ItemTemplate>
The <%# Session["Session_player"] = DataBinder.Eval(Container.DataItem,
"playerID") %> display correctly in the Datagrid.

IŽam trying to get the player_details.aspx file to receive the current
player.
The spillerID will not be acceptet and now the Session["Session_player"] is
changed to contain the last value in the database insted.

Cmd = new OleDbCommand("SELECT * FROM tblPlayers WHERE PlayerID = " +
Session["Session_player"] + " ", Conn);

R./jp

"Scott Allen" <bitmask@[nospam].fred.net> skrev i en meddelelse
news:0d********************************@4ax.com...
Hi Jesper:

Keep the entire statement inside the data binding delimeters:

<%# Session["Session_player"] =
DataBinder.Eval(Container.DataItem, "playerID") %>

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sat, 23 Oct 2004 21:14:01 +0200, "Jesper Pedersen"
<jb*@microtus.dk> wrote:
This works fine:
<% Session["Session_player"]=1; %>
but this:
<% Session["Session_player"]=%> <%# DataBinder.Eval(Container.DataItem,
"playerID") %> <%; %>

do not work.

The playerID contains the value 1, so the values in both examples are the
same.
What do you suggest - where should i look ??

Nov 18 '05 #3
Hi Jesper -

If the data binding is inside of a Repeater or DataGrid, then it will
execute for each row in the data source. The last assignment will be
from the last row in the data source.

What you might want to do is add some logic so the assignment only
happens on a row that is selected. Look at the ItemDataBound event,
perhaps you could pull it out there. Alternatively, you could add some
additional logic to the data binding expression. See:

Digging Into Data Binding Expressions
http://OdeToCode.com/Articles/278.aspx

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sun, 24 Oct 2004 00:37:23 +0200, "Jesper Pedersen"
<jb*@microtus.dk> wrote:
Hi Scott !

Great...thanks.....now is works......nearly as planned.......

Now, I got to figure out why Session["Session_player"] contains the last
value in the database rather than the current value.

It is assigned in:
<ItemTemplate>
<a href="player_details.aspx?spillerID=<%#
DataBinder.Eval(Container.DataItem, "PlayerID") %>"
target="_parent"> <%# DataBinder.Eval(Container.DataItem,
"playerFirstName") %>
<%#
DataBinder.Eval(Container.DataItem, "playerLastName") %> </a>
<%# Session["Session_player"] =
DataBinder.Eval(Container.DataItem, "playerID") %>
</ItemTemplate>
The <%# Session["Session_player"] = DataBinder.Eval(Container.DataItem,
"playerID") %> display correctly in the Datagrid.

IŽam trying to get the player_details.aspx file to receive the current
player.
The spillerID will not be acceptet and now the Session["Session_player"] is
changed to contain the last value in the database insted.

Cmd = new OleDbCommand("SELECT * FROM tblPlayers WHERE PlayerID = " +
Session["Session_player"] + " ", Conn);

R./jp

"Scott Allen" <bitmask@[nospam].fred.net> skrev i en meddelelse
news:0d********************************@4ax.com.. .
Hi Jesper:

Keep the entire statement inside the data binding delimeters:

<%# Session["Session_player"] =
DataBinder.Eval(Container.DataItem, "playerID") %>

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sat, 23 Oct 2004 21:14:01 +0200, "Jesper Pedersen"
<jb*@microtus.dk> wrote:
This works fine:
<% Session["Session_player"]=1; %>
but this:
<% Session["Session_player"]=%> <%# DataBinder.Eval(Container.DataItem,
"playerID") %> <%; %>

do not work.

The playerID contains the value 1, so the values in both examples are the
same.
What do you suggest - where should i look ??


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: spiderman | last post by:
How can one 'assign' value of a session variable to a variable, something like: temp = session("variable") Thanks
1
by: Michelle Stone | last post by:
Hi all. I have an empty datagrid on my web form. And I add BoundDataColumn(s) to it through code. But after each postback, the columns and rows disappear. As a workabout, I tried to rebind the...
2
by: Al Wilkerson | last post by:
Hey guys, I'm having problems with creating/storing a value in a session variable for later retrieving on another page. Here is the aspx page where I create/store the value ...
3
by: amjad | last post by:
Hi i have a webpage which has datagrid with one column called customer ID.. that customer ID is hyperlink mean i a click that customer ID it open a web page and display that customer ID on that...
2
by: Mirovk | last post by:
Hi, I have a session variable wich value arrives from a previous .asp but in my actual page I need to modify it based upon a selected value from a radio button. I will try to figure out for...
4
by: philin007 | last post by:
Hi , I have the following javascript codes: ****************************************** <script language="JavaScript"> <!-- .... ..... if (nextRow >5) {
5
by: aamirghanchi | last post by:
Hi, I need to know if anyone else came across this. The Session variable value I set in a sortCommand event handler of a datagrid does not hold on till the next sortcommand event handler and...
12
by: Kurda Yon | last post by:
I am wandering which way to assign a value to a session variable exist. Which of the following examples will work. Example #1: session_start(); session_register("ex"); $ex = 2.0; Example...
2
by: rahullko05 | last post by:
i am stuck in the problem, where after user logs in successfuly, i take him to the login thanks page. now on that page i need to retain the login name. I am not sure how to this. i have written a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.