Click here to Skip to main content
15,903,362 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Enabled/Disabled dropdownlist Pin
MissionSuccess3-May-06 0:10
MissionSuccess3-May-06 0:10 
QuestionDrop down list Pin
Balwan2-May-06 19:47
Balwan2-May-06 19:47 
AnswerRe: Drop down list Pin
CWIZO2-May-06 21:38
CWIZO2-May-06 21:38 
Questionbinding slides to grid Pin
sandip manoj2-May-06 18:53
sandip manoj2-May-06 18:53 
Questionuser/role management with atlas Pin
silverP2-May-06 15:04
silverP2-May-06 15:04 
AnswerRe: user/role management with atlas Pin
minhpc_bk2-May-06 15:53
minhpc_bk2-May-06 15:53 
Questiondelete row in dataset Pin
janetb992-May-06 11:37
janetb992-May-06 11:37 
Questionsession variable... Pin
jung19752-May-06 9:49
jung19752-May-06 9:49 
I have two pages A and B.

ON page A, I have three drop down boxes ( month , year, and unit_abbr and they have cascading and Auto post backs) and click button to run a report. What I am trying to do is keeping selected drop down list values after the postbacks. The problem right now is when I come back to page A after I browse page B , the selected values in dropdown boxes are set back to the default ( in my case most recent month, year, unit_num). How can I keep the selected values inside of dropdown lists while I am browsing around different pages? If I select month = 1 year 2006 unit_abbr = D11 to run the report on page A, then go to the different page to browse around different report and when I come back to Page A, the selected parameters in those drop down lists should be set to month = 1 year 2006 unit_abbr = D11

Here is my code using session variable:


<asp:label id="Label4" runat="server" text="Select Year:" forecolor="Black" font-bold="True" font-names="Arial" font-size="8pt">



<asp:dropdownlist id="DropDownList2" runat="server" datasourceid="SqlDataSource3" datatextfield="year" datavaluefield="year" font-names="Tahoma" font-size="8pt" autopostback="True" onselectedindexchanged="DropDownList2_SelectedIndexChanged1">







<asp:label id="AccountStatus" runat="server" font-size="16pt" visible="False" width="87px">







<asp:label id="Label5" runat="server" text="Select Month:" forecolor="Black" font-bold="True" font-names="Arial" font-size="8pt">



<asp:dropdownlist id="DropDownList1" runat="server" datasourceid="SqlDataSource2" datatextfield="month" datavaluefield="month" font-names="Tahoma" font-size="8pt" onselectedindexchanged="DropDownList1_SelectedIndexChanged" autopostback="True">











<asp:label id="Label7" runat="server" text="Select Region:" forecolor="Black" font-bold="True" font-names="Arial" font-size="8pt">



<asp:dropdownlist id="DropDownList4" runat="server" autopostback="True" datasourceid="SqlDataSource6" datatextfield="region_name" datavaluefield="Region_num" font-names="Tahoma" font-size="8pt" onselectedindexchanged="DropDownList4_SelectedIndexChanged">





 











--Here is code behind

public

partial class Dashboard : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{



if (!Page.IsPostBack && ((this.Session["MMselectedvalue"] != null) && (this.Session["YYselectedvalue"] != null)


if (!Page.IsPostBack && ((this.Session["MMselectedvalue"] != null) && (this.Session["YYselectedvalue"] != null) && (this.Session["Unitselectedvalue"]) != null) && (this.Session["Regionselectedvalue"] != null))
{


this.DropDownList1.SelectedIndex = Convert.ToInt32(this.Session["MMselectedvalue"]);

this.DropDownList2.SelectedIndex = Convert.ToInt32(this.Session["YYselectedvalue"]);

this.DropDownList3.SelectedIndex = Convert.ToInt32(this.Session["Unitselectedvalue"]);

this.DropDownList4.SelectedIndex = Convert.ToInt32(this.Session["Regionselectedvalue"]);
GridView4.DataBind();

}


protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{


this.Session["MMselectedvalue"] = this.DropDownList1.SelectedIndex;
}




protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{


this.Session["YYselectedvalue"] = this.DropDownList2.SelectedIndex;
}


protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{


this.Session["Unitselectedvalue"] = this.DropDownList3.SelectedIndex;

protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)
{


this.Session["Regionselectedvalue"] = this.DropDownList4.SelectedIndex;



But, the problem is the data controls of drop downboxe ( sql datasource) are overwriting the session varialbles, so it set back to the default value...

How can I keep the session variables after the data binding ( sql datasource for drop downboxes)? ,and How can I ditermine whether it's just a postback ( changing selected values on the same page) or the user is actually changing the page( navigate different pages and come back to the same page).?
AnswerRe: session variable... Pin
CWIZO2-May-06 19:15
CWIZO2-May-06 19:15 
GeneralRe: session variable... Pin
Paddy Boyd2-May-06 23:52
Paddy Boyd2-May-06 23:52 
GeneralRe: session variable... Pin
jung19753-May-06 2:27
jung19753-May-06 2:27 
GeneralRe: session variable... Pin
jung19753-May-06 2:26
jung19753-May-06 2:26 
QuestionDataGrid cell color problem Pin
alexfromto2-May-06 9:37
alexfromto2-May-06 9:37 
AnswerRe: DataGrid cell color problem Pin
Jakob Farian Krarup2-May-06 21:19
Jakob Farian Krarup2-May-06 21:19 
GeneralRe: DataGrid cell color problem Pin
alexfromto3-May-06 2:16
alexfromto3-May-06 2:16 
Questionclient ip address...Help? Pin
haneen19842-May-06 8:54
haneen19842-May-06 8:54 
AnswerRe: client ip address...Help? Pin
Dinuj Nath2-May-06 20:15
Dinuj Nath2-May-06 20:15 
GeneralRe: client ip address...Help? Pin
haneen19842-May-06 23:02
haneen19842-May-06 23:02 
Questioni changed my email Pin
waleed992-May-06 7:47
waleed992-May-06 7:47 
Questionserver free Pin
waleed992-May-06 7:46
waleed992-May-06 7:46 
Questionusing payment methods in a website Pin
steve_rm2-May-06 7:03
steve_rm2-May-06 7:03 
AnswerRe: using payment methods in a website Pin
HimaBindu Vejella2-May-06 19:09
HimaBindu Vejella2-May-06 19:09 
QuestionHow to make child links to my "Admin" link on the Master Page? Pin
Slow Learner2-May-06 6:43
Slow Learner2-May-06 6:43 
QuestionExporting a .net page with grid views and graphs into pdf.. Pin
esesem2-May-06 6:24
esesem2-May-06 6:24 
QuestionDetermining i a file is an image Pin
Ista2-May-06 5:09
Ista2-May-06 5:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.