C# - DropDownList Items Are Reset On SelectedIndexChanged?

Sep 17, 2010

I have a cascading dropdown list on my page. The first dropdown contains a list of events. The second dropdown contains a list of attendees. When an event is selected, an AJAX call is made to get the list of attendees for that event, and populate the second dropdown.

My problem is that for the attendees dropdown, I want the user to be redirected to a URL on the SelectedIndexChanged event, with the selected value in the query string. But on the SelectedIndexChanged event, all the items in the second dropdown are reset. Here's my code:

<script type="text/javascript" language="javascript">

$(document).ready(function()
{
$('#<%= ddlEvents.ClientID %>').change(function()
{
$.ajax({

[Code]....

When the SelectedIndexChanged event is hit, ddlAttendees is empty.

Does anyone know how I can keep the items in ddlAttendees?

View 2 Replies


Similar Messages:

Web Forms :: Unselect Selected Items In Listbox After SelectedIndexChanged?

Oct 24, 2010

i have a listbox LbGeneratedExcelLinks when i click inside of it on an item it download the selected item

here s my code

Protected Sub LbGeneratedExcelLinks_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LbGeneratedExcelLinks.SelectedIndexChanged
Dim RedirectUrl As String = LbGeneratedExcelLinks.SelectedValue
Response.Redirect(RedirectUrl)
LbGeneratedExcelLinks.SelectedIndex = Nothing
End Sub

problem is if i want to click on another button or other event it keeps showing the dialog open or save file the one i put inside selectedindexChanged

unselect after the selectedindexchanged i think it will solve my problem

View 4 Replies

Data Controls :: Fire RadioButtonList / SelectedIndexChanged Event Conditionally For Some Items?

Oct 22, 2013

i read article "using javascript with asp.net radiobuttonlist control" and i found it useful.

[var RB1 = document.getElementById("<%=RadioButtonList1.ClientID%>");
var radio = RB1.getElementsByTagName("input");
if am setting radio[1].checked = 1; the item is checked. ]

step1: radio[0]=checked
           radio[1]=not checked
            radio[2]=not checked

step 2: by using javascript , am changing the selection

now 

           radio[0]=not checked
           radio[1]=checked 
          radio[2]=not checked

step 3: if am changing radio[0]=checked by clicking, it wont fire the selected index change that i wrote on code behind

but if am changing radio[2]=checked by clicking, it will fire the selected index change that i wrote on code behind

My requirement: i want to fire the selected index change in both cases. for that i need to change the selected index in step 2.

View 1 Replies

Dropdownlist Does Not Trigger The SelectedIndexChanged?

Nov 9, 2010

I have a dropdownlist (dr1) that is supposed to trigger the update of dr2 without affecting dr3. The problem is that dr1 triggers the update, but does not go into dr1_SelectedIndexChanged. I know that because the label does not change and that the pause does not happen

Here is my HTML code:

<form runat="server">
<asp:ScriptManager ID="sm" runat="server" />
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="5">
<ProgressTemplate>

[Code]....

View 3 Replies

DropDownList SelectedIndexChanged Reverting To Some Other Value

Sep 21, 2011

There are a couple of things going on in this post:

1. The DropDownList (DDL) reverts back to index = 1 on postback (this has been solved, post #10)
2. Use of General Lists to populate the DropDownList (Post# TBD)

I have a series of DropDownLists (DDLs) one depending on the other for its selection value. The first one specifies the table name. On the SelectedIndexChanged event of the table name DDL the second DDL is populated with a list of field names contained in that table. And the third DDL with unique values contained in the selected field (In case you are wondering I am building a custom query tool).

The problem is that the Field names DDL, after selecting a new field, reverts to the second field listed in the table, something to do with the postback I would presume. The interesting thing is that it does not happen for the Table name DDL, though I am doing something a trifle bit different there.

I'll include the code for the three DDLs and the two SelectedIndexChanged events.

ASPX:
<td> <asp:DropDownList ID="DDL_TableNames" runat="server" AutoPostBack="True">
</asp:DropDownList>
</td> <td>
<asp:DropDownList ID="DDL_FieldNames" runat="server" AutoPostBack="True">
</asp:DropDownList>

[Code] ....

View 12 Replies

C# - Why DropDownList.SelectedIndexChanged Event Does Not Fire

Feb 9, 2011

I have a DropDown which is bounded to an ObjectDataSource. On its data bound event, I am adding "--select--" value on the 0 index. I have a LinkButton on the page and on its client click, i am selecting different item on drop down (using JavaScript). Suppose there are 3 items like --select--, option1, option2 and option3 and now on link button's client click i selected option3, now if I select the default value "--select--", it does not fire the SelectedIndexChanged event. If I select any other value then it fires. Why does it not work for the default value?

[code]....

View 1 Replies

Radiobuttonlist SelectedIndexChanged When Changing Dropdownlist?

Sep 20, 2010

I have a radiobutton list that changes the contents of a dropdownlist when the selected radiobuttonlist index is changed using the SelectedIndexChanged event. Both controls are within the same updatepanel and both have autopostback set to true.

For some reason when I change the dropdownlist and cause a postback, the radiobuttonlist change event fires and repopulates the dropdownlist which effectively cancels the selection made in the dropdown.

I know something simple must be causing this behaviour but I cannot think what and my debugging efforts are not shedding any light thus far. I have tried putting a breakpoint on every procedure in my form and the first event that fires is the radiobuttonlist SelectedIndexChanged event so nothing in my server side code seems to be doing this which suggests it is something in the markup but I can't think what.

View 3 Replies

How To Fire Dropdownlist.selectedindexchanged Event Programmaticaly

Apr 21, 2010

I have some code which fires when user selects an item in dropdownlist. Now i want the same code to fire when i set selectedindex programmatically.

I have tried setting

ddlSystemLevelDCP.SelectedIndex=2;

and this as well

ddlSystemLevelDCP.SelectedValue="2";

None of them fires this event.However when user changes the selection,this event fires.Please tell me what am i missing.

View 1 Replies

Web Forms :: Dropdownlist Control SelectedIndexChanged Event?

Jun 22, 2010

I have one dropdownlist control which populates values to other controls. Means upon selecting item in dropdownlist, related data is populated in other controls. I have also assigned dropdownlist's autopostback to TRUE. Everything is working good as far as dropdown has more than one item.

Whenever there is only one item, selectedindexchanged event is not fired (obviously.....) and eventually the data is not populated to other controls.

How could I get rid of this scenario? I mean which event should I use to avoid this?

At this time, I have just added the first item as something like "---Select Item---" , so when end-user has to select different item and thus the selecteditemindexchanged is fired. no biggie... but just wondering if proper solution is available....

View 3 Replies

Dropdownlist Selectedindexchanged Event Inside A Formview?

Apr 25, 2010

I have a dropdownlist inside a formview and I'm trying to do something on the selectedindexchanged event. but I'm getting the following error:

It looks like it can't find the dropdownlist because it is inside the formview. How can I find the event?- if there is such a thing.

Server Error in '/WebSite4' Application. Compilation Error
Description:

An error occurred during the compilation of a resource required to service this request.

review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

Source Error:

[Code]....

Line 13:End If
Line 14:End Sub
Line 15:Protected Sub ddlDept_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlDept.SelectedIndexChanged
Line 16: Dim ComDropDownList As DropDownList = CType(FormView1.FindControl("ddlCommune"), DropDownList)
Line 17:

View 8 Replies

SelectedIndexChanged Fires For A DropDownList When A Button Is Clicked?

Mar 16, 2010

I have an ASP.NET DropDownList with AutoPostBack=true and EnableViewState=false. I have a button on the page that does nothing. If I change the selection in the ddl, it posts back , which is expected. If I click the button, the page posts back and the ddl's SelectedIndexChanged fires. Why does it get fired?

View 3 Replies

Web Forms :: Reset DropDownList After PostBack

Apr 1, 2010

I have a situation where i want to postback and redirect the user to the diffterent page wherever the user selects something from dropdown list. If the user presses the back button the in the browser the dropdownlist should be in the default state. i have already tried this code

protected void ddl_SelectedIndexChanged(object sender,Eventargs e)
{
int selecteditem = int.Parse(ddl4.SelectedItem.Value.ToString());
ddl.ClearSelection(
ddl.Dispose();
//Even tried ddl.selectedindex = -1 ;
//dosome postback i.e redirecting the user depeneding upon the value in selecteditem
}

View 8 Replies

Web Forms :: Unexpected Dropdownlist SelectedIndexchanged Event Firing?

Mar 2, 2011

Getting an unexpected event firing dropdownlist's selectedIndex event. When I try to redirect from another page by a linkButton. I just changing dropdownlist selectedIndex.Its okay.But after that When I attempt to redirect to another page,DropDownList's selectedIndex event firing (before linkButton Onclick event).But I am not changing any thing in dropdownlist.Somehow its event firing.

also any page viewstates is default (not off).But loading webcontrols into masterpage Page_Load like this :

[Code]....

if this dropdownlist selectedIndexchanged event firing. Because of I am loading webcontrols each masterpage's PageLoadEvent.

What do you prefer this may the reason of this unexpected event firing ? if so. Do you have a better technic to load controls Just for one time and not each pageLoad.maaybe a caching technic I am missing or shoult I use substution.

I couldnt find the main reason why a dropdownlist selectedIndexchanged event firing without I changed anything on that dropdownlist.

what reasons may cause this problem ? if you say viewstate its turned on defaultly. any other reason you know why ?

View 2 Replies

Web Forms :: DropDownList - How To Initiate SelectedIndexChanged If Only One Item In List

Nov 30, 2010

I have several DropDownLists which get data from database, that is,

first DropDownList has static data, second DropDownList gets data according to selectedItem of first DropDownList, and so on..

There cases when second DropDownList has only one item, in that case I cant call SelectedIndexChanged.

How to manage it ?

View 1 Replies

Web Forms :: Show/Hide Image On Dropdownlist SelectedIndexChanged?

Mar 12, 2010

Basically I have a dropdownlist (ddlSystem) and an AJAX update panel. Inside the update panel I have an asp:GridView (gvSystemSpecs) and an asp:Image (imgLoad).

For triggers on the update panel I have:

[Code]....

When the user changes ddlSystem it makes a service call to pull back a bunch of data and populate the gridview.

I want to be able to show a loading image (imgLoad) when ddlSystem is changed. Once the function to pull data and populate the gridview is complete I need to hide the loading image.

I think I'll need to use some JavaScript, but what ever I try doesn't work and I don't know if the update panel has anything to do with it...

View 2 Replies

Web Forms :: How To Get Dates From Db To Calendar Using Dropdownlist SelectedIndexChanged Event

Jan 11, 2011

I want to get dates from Database to a calendar > on a dropdownlist Selection.. This is what i was doing on page load

[Code]....

I tried using it in dropdownlist SelectedIndexChanged but something is not right! here is the rest of the code for dayrendar event and

[Code]....

What should i do ?

View 18 Replies

Web Forms :: Dropdownlist Selectedindexchanged Event Working Slow In Ie8

Jan 8, 2011

i am using dropdownlist selectedindexchanged event , it is working with good speed in ie 6 or ie 7. But working slow in ie8.

View 2 Replies

Web Forms :: Dropdownlist Selectedindexchanged Not Working With Autopostback = True

Jan 19, 2010

i have two dropdownlist in my webform both are filled dynamically in the page_load event

[Code]....

View 8 Replies

C# - Dropdownlist Selectedindexchanged Event Doesnt Change Its State?

Feb 1, 2011

In the following code everytime its taking only one item from dropdownlist. When I select any other item from dropdownlist its same as first item.

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet _subcat = new DataSet();
_subcat = serviceus.Get_SERVICEUS_SUB_CATEGORYLIST(DropDownList1.SelectedValue.ToString());
lbsubcategory.DataSource = _subcat.Tables[0].DefaultView;
lbsubcategory.DataTextField = Convert.ToString(_subcat.Tables[0].Columns["CATEGORY_SUB1_NAME"].ColumnName);
lbsubcategory.DataBind();
Label5.Visible = true;
}

View 3 Replies

Forms Data Controls :: DropDownList.SelectedIndexChanged Not Working

Nov 11, 2010

I have the following in a web user control:

asp:DropDownList
ID="ddlPrescriptionCodeGroup"
runat="server"
AppendDataBoundItems="True"
AutoPostBack="True"
DataSourceID="PrescriptionCodeGroupDataSource"
DataTextField="CodeGroupDescription"
DataValueField="PrescriptionCodeGroupID"
onselectedindexchanged="ddlPrescriptionCodeGroup_SelectedIndexChanged">
<asp:ListItem
Text="--Please Select--"
Value="-1"></asp:ListItem>
<
</asp:DropDownList>
<asp:SqlDataSource
ID="PrescriptionCodeGroupDataSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:RadiotherapyConnectionString %>"
SelectCommand="SELECT [PrescriptionCodeGroupID], [CodeGroupDescription] FROM [PrescriptionCodeGroup] WHERE (([Archived]
= @Archived) AND ([OrganisationID] = @OrganisationID))">
<SelectParameters>
<asp:Parameter
DefaultValue="False"
Name="Archived"
Type="Boolean"
/>
<asp:SessionParameter
Name="OrganisationID"
SessionField="OrganisationID"
Type="Int32"
/>
</SelectParameters>
</asp:SqlDataSource>
<asp:DropDownList
ID="ddlPrescriptionCode"
AutoPostBack="True"
runat="server"
AppendDataBoundItems="True"
onselectedindexchanged="ddlPrescriptionCode_SelectedIndexChanged"
DataSourceID="PrescriptionCodeDataSource"
DataTextField="CodeDescription"
DataValueField="PrescriptionCodeID"
>
<asp:ListItem
Text="--Please Select--"
Value="-1"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource
ID="PrescriptionCodeDataSource"
runat="server"
ConnectionString="<%$ ConnectionStrings:SystemConnectionString %>"
SelectCommand="SELECT [PrescriptionCodeID], [CodeDescription] FROM [PrescriptionCode] WHERE (([Archived] = @Archived)
AND ([PrescriptionCodeGroupID] = @PrescriptionCodeGroupID))">
<SelectParameters>
<asp:Parameter
DefaultValue="False"
Name="Archived"
Type="Boolean"
/>
<asp:ControlParameter
ControlID="ddlPrescriptionCodeGroup"
Name="PrescriptionCodeGroupID"
PropertyName="SelectedValue"
Type="Int32"
/>
</SelectParameters>
</asp:SqlDataSource>

When I select from the first dropdown I want to populate the second. However, this is not happening. The postback is happening, but the SelectedIndexChanged handler isn't being called (I have a breakpoint which isn't being hit). The user controls are created dynamically and put into a PlaceHolder which itself is within an AJAX Updatepanel, with ChildrenAsTriggers set to true.

View 12 Replies

Data Controls :: DropDownList SelectedIndexChanged Event Not Firing

Jun 6, 2013

I take drop down list control ,from below code i bind data into drop down list from database...

public void load() {
try {
string sCon = gv.constr;
MySqlConnection con = new MySqlConnection(sCon);
con.Open();
String s = "Select * from company";
MySqlCommand cmd = new MySqlCommand(s, con);

[Code] ...

I used to done select index change event on  drop down list bt it's not working... I want select index value of drop down list item into textbox....wat i do?

protected void drpOrg_SelectedIndexChanged(object sender, EventArgs e){
string sCon = gv.constr;
MySqlConnection con = new MySqlConnection(sCon);
con.Open();
String s = "Select companyid from companyuser where orgname='"+drpOrg.SelectedValue.ToString()+"'";

[Code] ....

View 1 Replies

DropdownList Reset In Updatepanel On Submit Button?

Oct 7, 2010

I have a dropdown list which is in updatepanel. I have to fill that dropdown on a client event through javascript which calls __dopostback of the updatepanel and calls its load event.

Problem is that when i submit the form updatepanel_Load event also execute again and it again reset the DropDownLIst which causes the loss of selectedValue in Dropdown.

<asp:UpdatePanel ID="UpdatePanel3" runat="server" OnLoad="UpdatePanel3_Load" UpdateMode="Conditional">

<ContentTemplate>


<asp:DropDownList ID="ddlItems" runat="server" CssClass="dropdown">
</asp:DropDownList>

</ContentTemplate>
</asp:UpdatePanel>

On page Load this dropdown is Empty .... no funtion to fill it.Now the problem is when ever I Fill the Dropdown throught Load of UPatepanel, that UPdatepanel Load event also execute when I submit my page. Actually the solution of javascript is due to a table and on Selection of the table row item it Fills the DropDownList from __dopostback of my updatepanel.

I have button which opens a popup window and that popup window contains a table, when client select some item from that table and close that popup window then I fill my dropdown (in parent or opener page through Ajax, Updatepanel's Load) as further selction option. so dropdown databind is dependent on that tables input.

View 2 Replies

Web Forms :: Retrieve DropDownList SelectedIndexChanged Event In Content Page?

Apr 28, 2010

I have in my MasterPage a DropDownList that appears in all my Pages. I want it to run a specific code when user select another item in the list, but the event SelectedIndexChanged in the MasterPage doesn't work. How can I do to get this event working?

View 1 Replies

DropDownList In ModalPopup / UpdatePanel Intermittently Doesn't Fire SelectedIndexChanged

Feb 4, 2010

I've got a UserControl that's used inside of an UpdatePanel. The UserControl is a fairly simple form that appears via a ModalPopupExtender (which is also part of the UserControl). There are four DropDownLists, as well as some other UI elements. Three of the four DropDownLists have AutoPostBack="true", with SelectedIndexChanged events that fire on the server and cause some of the other DropDownLists to rebind. Two of the three DDL's that AutoPostBack are working fine. One of them, which I only just added, is showing some strange behavior. Let's say I bind five Items to it: 1, 2, 3, 4, 5. I set the SelectedIndex to 0, which makes 1 the selected item. If I select 5 and then 1 and keep toggling back and forth, everything works fine. The postback occurs and SelectedIndexChanged fires. Every time. If I ever select 2 or 4, the postback occurs but SelectedIndexChanged does not fire. Every time.

If I ever select 3, something bizarre happens and sometimes the value of the DDL reverts to 1. Even though breakpoints seem to show that it's not rebinding and no unexpected code is running. I know your first instinct will probably be that I'm wrong about the rebinding code not running, but I have literally been staring at the debugger for hours trying to find my mistake. Lots of breakpoints. I don't get it -- this really isn't that complicated. But obviously I am missing something. I've put about four hours into this so far and I think I'm just grinding at this point. I could use another perspective.

HTML (and by the way, DropProtocolCycleID is the problem control):
<asp:Panel ID="PanelPopupAssign" runat="server" Style="display:none; cursor: move; width:325px; background-color:Transparent;">
<BlueUI:Panel runat="server" ID="PanelPatientProtocol" Width="500px" HeaderText="Assign Protocol">
<table cellspacing="5">
<tr>
<td style="width:150px;"></td>
<td style="width:50px;"></td>
<td style="width:125px;"></td>
</tr>
<tr runat="server" id="TableRowCategory">
<td align="right">Category:</td>
<td colspan="2">
<asp:DropDownList runat="server" ID="DropProtocolCategories" CausesValidation="false" autopostback="true"/>
</td>
</tr>
<tr>
<td align="right">Protocol:</td>
<td colspan="2">..............................

View 2 Replies

SelectedIndexChanged Event Doesn't Fire When Create A Dropdownlist In Code-behind

Dec 9, 2010

I create a dropDownList in code-behind, in selectIndexChange of another dropDownList, and add this new dropDownList to page using a placerHolder, everthing its ok, but new dropdownlist selectIndexChange event dont fire!

code of dropDownList creation

dropDown = new DropDownList();
dropDown.AutoPostBack = true;
dropDown.ID = idSubistema;
dropDown.Width = 400;
dropDown.CssClass = "controltext";
dropDown.DataValueField = "IDNivel";
dropDown.DataTextField = "NIVEL";
dropDown.EnableViewState = true;
dropDown.DataSource =
DBLibray.DefinitionIndicadores.spSelect_FillCombosWithNivelByIdParent(
ref dataConnector,
Convert.ToInt32(idSubistema));
dropDown.DataBind();
dropDown.SelectedIndexChanged += new EventHandler(indexChange);
//dropDown.PreRender += new EventHandler(dropDown_PreRender);
placeHolderForCombos.Controls.Add(new LiteralControl("<div>"));
placeHolderForCombos.Controls.Add(lb);
placeHolderForCombos.Controls.Add(new LiteralControl("<br>"));
placeHolderForCombos.Controls.Add(dropDown);
placeHolderForCombos.Controls.Add(new LiteralControl("</div>"));
placeHolderForCombos.Controls.Add(new LiteralControl("<br>"));

View 2 Replies







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