C# - Dropdownlist In Masterpage Value Not Updated After New Selected?

Mar 30, 2011

I have a dropdownlist implemented in my masterpage. It has an sql data source from which it loads the values of companies. Depending on which value(company) selected, it shows that value in a label on a different page. The ddl which is in the masterpage is ofc still visible and should display the selected value which it does at the 1st time a value is selected. But when i select another value in the ddl it shows the value which was 1st selected and so on. So it doesn't update or something.

My code:

This is the onselectedIndexChanged event handler:

protected void DropDownListType_SelectedIndexChanged(object sender, EventArgs e)
{
String input1 = DropDownListType.Text;
String input2 = DropDownListType.SelectedValue;
String url = "~/test.aspx?pcompany="+input1;
DropDownListType.SelectedValue = input2;
Session["Company"] = input2;
Response.Redirect(url);
}

and this is the code i'm using in my Page_load method from the masterpage:

if (Session["Company"] != null)
{
DropDownListType.SelectedValue = (String)Session["Company"];
}

If I remove this last piece of code from my page_load method it updates the label with value on the redirected page but it resets my ddl to default value instead of keeping it at 4 when value 4 selected.

View 3 Replies


Similar Messages:

Web Forms :: Child Not Updated If Master Dropdownlist Selected Value Changed Programatically

May 28, 2010

In my application i have a 'Result.aspx' page. In this page i have a dropdownlist which is acting as a master for a gridview. I want that when the user loads this page then the dropdownlist automatically has the value which user selected on another page and for this i am using querystring in the page load event as follows

ddlSelectCoupon.SelectedValue =Request.QueryString("partID")

I have set the autopostback of dropdownlist to True

My problem is if i am assigning the value to dropdownlist this way then my child gridview is not updating. Also, what is the best page event for assingning this value

View 4 Replies

C# - Selected Item Not Being Updated?

Mar 25, 2010

I've got the following DropDownList control:

<asp:DropDownList ID="SubjectFilter" runat="server" AutoPostBack="True" onselectedindexchanged="SubjectFilter_SelectedIndexChanged"></asp:DropDownList>
SubjectFilter data:
BookStore b = new BookStore();
b.LoadFromXML(Server.MapPath("list.xml"));
SubjectFilter.DataSource = b.BooksList.Select(x => x.Subject).Distinct().ToArray();
SubjectFilter.DataBind();
SubjectFilter.Items.Insert(0, new ListItem("הכל", "Default"));

Everything loads just fine. However in the SubjectFilter_SelectedIndexChanged method, SubjectFilter.SelectedValue is always Default, even though I'm selecting different options.

View 4 Replies

C# - Disable Or Enable 2nd Dropdownlist In Aspx Based On Selected Choice Of The 1st Dropdownlist Box

Apr 15, 2010

I am having a problem with disabling DropDownList based on the chice of 1st DropDownList, there is no post back occuring, and it is a template based web app here is the current code:

<script type="text/javascript">
$(function() { var dropDownList1 = $('#<%= ddlUserType.ClientID %>');
var dropDownList2 = $('#<%= ddlMember.ClientID %>'); dropDownList1.change(function(e) {
if ( jQuery("#ddlUserType").val() != "ETOC") dropDownList2.removeAttr('disabled'); e.preventDefault();
else
dropDownList2.removeAttr('enabled'); e.preventDefault(); }
} );
</script>

what is happening now is page is blank and if I remove the above code everything shows, where I am going wrong. here is the plain and final javascript code which worked:

<script language="javascript">
function CheckDropDownState(lstbox)
{
if (lstbox.selectedIndex == 3) { document.forms[0].ddlMember.disabled = 1; }
else { document.forms[0].ddlMember.disabled = 0; }
}
</script>

and thew .aspx code: <asp:dropdownlist id="ddlUserType" runat="server" onclick="CheckDropDownState(this);"></asp:dropdownlist>

View 2 Replies

Web Forms :: Display All Items In Child DropDownList When ALL Is Selected In Parent DropDownList

Sep 6, 2012

protected void DDLzone1_SelectedIndexChanged(object sender, EventArgs e)
{
BindDistrict();
}

[Code]......

here when i click on ALL item from ddlzone1  it just "ALL" item in ddldistrict

i want when i select "ALL" item from ddlzone1 in ddldistrict14 show all data from database

View 1 Replies

State Management :: Cascading Dropdownlist Will Not Reload With Updated Database Data Unless End And Restart

May 19, 2010

I have a cascading dropdownlist. The first drop down is for Departments and is databound on PageLoad from the database. The user then selects a department and the second dropdown is populated with the appropriate sub departments via JQuery/JSON which calls an httphandler. The problem is as follows: I select a department and the subdepartments are filled.

I finish what I'm doing on that screen and everything is fine. But then if I go to a different screen and add an additional subdepartment then come back to original screen, the new sub department won't appear in the cascading dropdown. I have to close the browser and restart the session in order for any new sub departments to appear even though they are in the database. I put a breakpoint in the httphandler and noticed that it is only called once per session per each department in the first dropdown. I don't know why this is happening. I want it to call the httphander EVERY time the index of the department dropdown is changed.

[Code]...

View 3 Replies

Disabling Dropdownlist Inside A Gridview Based On Value Selected On Another Dropdownlist?

Jan 11, 2011

what i m trying is i hav two dropdownlists inside the gridview... namely say ddonsiteoffsite and ddhours... now what i want is if the selectedtext of ddonsiteoffsite is "onsite" the ddhours should b disabled... i tried the code snippet but ... its not disabling the ddhours... can someone help me please..

<asp:TemplateColumn HeaderText=" OnSite/OffSite" >
<ItemTemplate>
<asp:DropDownList ID="ddOnsiteOffside" runat="server" onchange="ToggleOnOff(this)">
[code].....

View 2 Replies

Data Controls :: How To Fill Second DropDownList When First DropDownList Value Is Selected

Dec 17, 2012

I am having a 2 dropdown list, in the first dropdown I have 3company names,for each company I am having separate tables,every table have a empcode, if the user select the  company name in the 1st dropdownlist, as per company selected the 2nd dropdownlist it will fill the  list of employee codes as per the selection..

View 1 Replies

Web Forms :: Display Selected Value Of One DropDownList In Another DropDownList On Different Page

May 7, 2015

I have two pages manager and user both have drop downs as 

Week, Months and Years.

User have to enter some data week wise for each months and Manager have to approve that.

To Approve manager select months and week from dropdown on his own page and then navigate to User page.

How does I should bind the drop down so that if manager select 1st week from it's page and goes to view link of user then in drop down of user selected value shold be the same as selected by Manager on his own page.

View 1 Replies

AJAX :: Updatepanel And Dropdownlist In A Masterpage?

Apr 26, 2010

firstly,i am going nuts with this problem. here it is:

i have a masterpage that contains a dynamically populated dropdownlist. i have autopostback =true and an onselectedindexchanged function. users user the dd to choose from a list of accounts that are available to them to edit/view. this portion works great. users pick an option and it postsback with the correct item. the item chosen gets set in the users profile so it defaults to it next time they log in.

now the problem arises on certain pages that use this masterpage. the child page has a timer, an updatepanel, and a gridview inside the updatepanel. the timer tick event fires and calls databind for the gridview. this all works great---EXCEPT, if the timer ticks while i am looking through items in the dropdownlist, the gridview updates, but also THE ONSELECTEDINDEXCHANGED event fires for the dd, even though i haven't actually clicked the dd to change it. just clicked it to make the dropdown active to
see its items. once the timer ticks, it automatically selects the dd item that i happen to be on... it is as if the updatepanel is causing a full page refresh.

i can use the timer_tick event to set label values, and it works like an update panel should....only updating the content inside the updatepanel. it is only when i am trying to choose an item from the dd in the masterpage that a full postback occurs. this creates a problem, because whatever item in the dd i happen to be on when the timer ticks is the one that gets selected. the selectedindexchaged event is supposed to call a full postback, but not the updatepanelupdate caused from the timer tick. my dropdownlist in masterpage

[Code]....

View 2 Replies

Web Forms :: Find DropDownList Control In MasterPage And Get Its Values

Sep 4, 2012

I have threee dropdownlist's which are varchar in master page and one dropdownlist in current page which is of int datatype. At present in current page I'm using  LIKE '%' for all dropdownlist's. I need to pass dropdownlist vlaues as parameter to sql. 

View 1 Replies

Should The Selected Index Or Selected Value Be Used To Set A Dropdownlist

Nov 26, 2010

I am binding months to a list 0-13 items default selection is 0 months duration, and years 0-8 items and 0 years is the default selection.As I know there are always going to be 12 months in a year, I could use selectedvalue or selectedindex without any perceived problem. Is there a reason why I should not use either/or of the two properties to select a list item?

View 2 Replies

SQL Server :: Why Are All Columns Updated Not Just The One Wanted Updated

Nov 21, 2010

Here is my code. I just wanted to update one column. Why is everything getting NULL put into it?

[Code]....

[Code]....

View 5 Replies

DropDownList / Based Off What Is Selected As The Dropdownlist?

Oct 6, 2010

I am trying to make a simple dropdownlist.Based off what is selected as the dropdownlist, I want it to open a new webpage.

For example:

Here is the dropdownlist - If they select team1, I want it to open up webpage /team1.aspx If it's team2, team2.aspx and so on.

<form id="form1" runat="server">

View 2 Replies

MVC :: Dropdownlist Is Accepting "selected" But Isn't Rendering That Option As Selected

Sep 30, 2010

I thought this would be pretty simple, and in fact it's working on another dropdownlist on the same View, so I'm hoping I missed something very small that is easy to fix. Here's my code:

[Code]....

When I step through the code, the 'Active' option's 'Selected' property is being set to true. That's expected. But when the View renders, it's not selected and a look at the page source shows that the selected property isn't set. What is the problem here, and what's the solution?

View 10 Replies

Dropdownlist - "Cannot Have Multiple Items Selected In A DropDownList.&quot?

Apr 29, 2010

how i handle this problem..Its in hidden filed.

Server Error in '/DentalClaimPrjt' Application.

Cannot have multiple items selected in a DropDownList.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Cannot have multiple items selected in a DropDownList.

Source Error: [Code]....

Line 85: function openPopup2(did)
Line 86: {
Line 87: var hdnClm1 = document.getElementById('<%=hdnCliamid.ClientID%>').value;
Line 88: window.location="Form.aspx?DeleteRSPid=" + did + "&Editid="+ hdnClm1;
Line 89: }

Source File: d:DentalClaimPrjtForm.aspx Line: 87 Stack Trace: [Code]....

[HttpException (0x80004005): Cannot have multiple items selected in a DropDownList.]
System.Web.UI.WebControls.DropDownList.VerifyMultiSelect() +106
System.Web.UI.WebControls.ListControl.RenderContents(HtmlTextWriter writer) +124

View 2 Replies

Second Dropdownlist Changes When First Selected?

Feb 7, 2010

Now I'm stuck in changing the second dropdownlist. For example, first dropdownlist- select 2, second dropdownlist will change from 1,2,3,4 to 2,3,4,5,6. Other than cascading dropdownlist, it there anyother methods?

View 1 Replies

Getting The Selected Value Of A Dropdownlist

Dec 16, 2010

I have an issue getting the selected value of a dropdownlist.

My view source looks like this:

[code]....

The problem is that Request.Form["DivisionesLists"] returns "1,1" instead of just "1" (which is the actual selected value of the dropdownlist).

View 2 Replies

VS 2008 Put Selected Value In DropDownList?

Aug 29, 2010

Is it right way to get the selected values in DropDownList

Code:
cmbType.SelectedValue = reader.Item("HeadName")
or Please suggest the right way

I m getting the below error on this line

'cmbType' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value

View 9 Replies

C# - How To Get Selected Value From Dropdownlist Using Javascript

Mar 9, 2010

i am populating country dropdownlist from database.i need to select a value from dropdown list and assign it to textbox by using javascript.

Code:

var textboxId = document.getElementById("txtCountry");
var dropdownListId =document.getElementById("ddlLocation");
var e = document.getElementById("ddlLocation");
var strUser = e.options[e.selectedIndex].value;
document.getElementById(textboxId).value = strUser;
document.getElementById(textboxId).focus();

View 3 Replies

MVC :: Set Selected Value In DropDownList Not Showing

May 30, 2010

On an action I have the following:

[Code]....

The days list shows fine but the selected value is not 2 but "---". Why?

View 3 Replies

Get Selected Value From Dropdownlist After Submit?

May 17, 2010

I populate DropDownList in ASP.NET webforms:

<asp:DropDownList runat="server" ID="salesman"></asp:DropDownList>

users= Buslayer.GetSalesRep(); [code]....

View 1 Replies

Get The Text Of The Name Selected In The Dropdownlist?

Jun 3, 2010

I have a dropdown list where the items displayed in the list are names, and the DropDownList selectvalue is Person_ID.

How do I get the text of the name selected in the dropdownlist and not the SelectedValue?

View 3 Replies

How To Get The Selected Value From A DropdownList Using JQuery

Aug 12, 2010

I have the following code and it gives me the text but not the value. What is wrong and how do I fix it?

[code]....

View 1 Replies

ADO.NET :: Dropdownlist Selected Value In Sql Command

Jan 12, 2011

I want to use (dropdownlist.selectedvalue) within sql command but i am getting an error ,, here is my code:

[Code]....

View 13 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved