Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » ASP 3.0




 Page 1 of 1 [ 7 posts ] 



Author Message
 Post subject: Settin the Session Var 4m the Dropdown List
 Post Posted: Sun Nov 22, 2009 12:57 pm 
Offline

Joined: Sat Feb 21, 2009 2:21 pm
Posts: 57
I m havin a dropdown list wid dis source code:

Code:
<asp:DropDownList ID="ddlProject" runat="server" DataSourceID="SqlProject" DataTextField="ProjectName"
            DataValueField="ProjectName">   



I have been trin to get da val of the dropdown box 2 be a session val
so all the subsequent pages would be the reference
ProjectName been selected. If da value in da dropdown list changes,
the session value would change as well.

I tried dis specific code behind statement:

Code:
Protected Sub ddlProject_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlProject.SelectedIndexChanged
        Session["Projectname"]=ddlProject
    End Sub


I have encountered an error:
Property access must assign 2 da property or use it was a value.

where waws i gone wrong!??


Top 
 Post subject: Re: Settin the Session Var 4m the Dropdown List
 Post Posted: Sun Nov 22, 2009 12:57 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
code]Session["Projectname"]=ddlProject.SelectedItem.Text[/code]

dun ver forget, that if you were populatin ur ddl in da Page Load event,
to surround it by an if/then/Postback block


Also, if da user chooses da same item that was already selectd in da
DDL, nothin seems to happens in da SelectedIndexChanged event


Top 
 Post subject: Re: Settin the Session Var 4m the Dropdown List
 Post Posted: Sun Nov 22, 2009 12:58 pm 
Offline

Joined: Sat Feb 21, 2009 1:08 pm
Posts: 549
Hi,

you must use:

Code:
Session["Projectname"]=ddlProject.SelectedValue


good luck


Top 
 Post subject: Re: Settin the Session Var 4m the Dropdown List
 Post Posted: Sun Nov 22, 2009 12:58 pm 
Offline

Joined: Sat Feb 21, 2009 2:21 pm
Posts: 57
I did get the same error

Am I supposed 2 place dis code on da dropdown list object r
somewhere else?

Code:
Protected
Sub ddlProject_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlProject.SelectedIndexChanged



Top 
 Post subject: Re: Settin the Session Var 4m the Dropdown List
 Post Posted: Sun Nov 22, 2009 12:59 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Use

Code:
Protected Sub ddlProject_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlProject.SelectedIndexChanged
        Session["Projectname"]=ddlProject.SelectedItem.Text
    End Sub


Top 
 Post subject: Re: Settin the Session Var 4m the Dropdown List
 Post Posted: Sun Nov 22, 2009 12:59 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Code:
   1. you should use the selected value or selectitem.text property of drop down.. 
   2.   
   3. do something like this.. 
   4.   
   5. session["drodownvalue'] = ddlProject.SelectedItem.Text ; 
   6.   
   7. or 
   8.   
   9. session["drodownvalue'] = ddlProject.selectedvalue; 
  10.   
  11.   
  12. one of these will solve your problem.. 

you should use the selected value or selectitem.text property of drop down..

do something like this..

Code:
session["drodownvalue'] = ddlProject.SelectedItem.Text ;

or

session["drodownvalue'] = ddlProject.selectedvalue;



one of these would solve ur issue .


Top 
 Post subject: Re: Settin the Session Var 4m the Dropdown List
 Post Posted: Sun Nov 22, 2009 12:59 pm 
Offline

Joined: Sat Feb 21, 2009 2:21 pm
Posts: 57
I m not quite sure wat u mean by:

If you r populatin ur ddl in da Page Load event, 2 surround it by an
if/then/Postback block


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 7 posts ] 




Board index » Server Side Development » ASP 3.0


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron