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


Similar Messages:

C# - Item In RadioButtonList Not Firing SelectedIndexChanged

Aug 10, 2010

I have a table cell with a RadioButtonList. When each item is selected, the SelectedIndexChanged event is supposed to fire so the app can populate a related listbox. The problem is it stopped working. Now if I selected the first entry 'Division', the event never fires. I put a break-point on the event handler and it gets called for the other entries but not for Division. I'd believe it if some other code is interfering, I just don't know where to start looking.

[update] By not working, I mean if you selected Item #2, the update works; then if you select Item #1 it doesn't. If I change where the 'Division' item appears in the list, it still has the problem. Is there something in the page load cycle that could be aborting the event handling chain?

private TableCell foo()
{
hierarchyLevel = new RadioButtonList();
ListItem DivisionItem = new ListItem();
DivisionItem.Text = "Division";
DivisionItem.Value = "afe_dvsn";
hierarchyLevel.Items.Add(DivisionItem);
ListItem DistrictItem = new ListItem();
DistrictItem.Text = "District";
DistrictItem.Value = "afe_dist";
hierarchyLevel.Items.Add(DistrictItem);
ListItem AreaItem = new ListItem();
AreaItem.Text = "Area";
AreaItem.Value = "afe_supt";
hierarchyLevel.Items.Add(AreaItem);
ListItem ForemanItem = new ListItem();
ForemanItem.Text = "Foreman";
ForemanItem.Value = "afe_frmn";
hierarchyLevel.Items.Add(ForemanItem);
ListItem AfeCodeItem = new ListItem();
AfeCodeItem.Text = "AFE Code";
AfeCodeItem.Value = "afe_code";
hierarchyLevel.Items.Add(AfeCodeItem);
ListItem PropertyItem = new ListItem();
PropertyItem.Text = "Property";
PropertyItem.Value = "prop_sub";
hierarchyLevel.Items.Add(PropertyItem);
TableCell cellforHierarchyLevel = new TableCell();
cellforHierarchyLevel.ID = "hierarchyLevel";
cellforHierarchyLevel.Controls.Add(hierarchyLevel);
hierarchyLevel.EnableViewState = true;
hierarchyLevel.AutoPostBack = true;
hierarchyLevel.SelectedIndexChanged += new EventHandler(hierarchyLevel_SelectedIndexChanged);
return cellforHierarchyLevel;
}

View 3 Replies

Uncheched RadioButtonList Doesn't Fire SelectedIndexChanged?

Apr 4, 2011

I have a RadioButtonList with some fixed element and a default selected. If I uncheck the selection with javascript, on postback the SelectedIndexChanged event is not fired.

I would expect that the SelectedIndexChanged is called because the index is changed to -1.

this is the Asp.Net code

<asp:RadioButtonList ClientIDMode="Static" ID="RadioButtonList1" runat="server"
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="1" Selected="True"></asp:ListItem>
<asp:ListItem Value="2"></asp:ListItem>
</asp:RadioButtonList>

and the jquery code

$('#RadioButtonList1 :radio:visible').attr('checked', false);

As far as I know, the stage of data collection from the submit of the form is handled by IPostBackDataHandler.LoadPostData method.

I derived a class from RadioButtonList to verify when LoadPostData is called and I noticed that when non of the radio button is selected the method is not called and the same for SelectedIndexChanged event.

it seems that if the key of RadioButtonList is not present in the Page.Request.Form.Keys array, the LoadPostData is not called.

View 1 Replies

Forms Data Controls :: RadioButtonList In GirdView - SelectedIndexChanged Did Not Get Triggered

Mar 15, 2011

I have a gridview and defined radiobuttonlist:

<asp:TemplateField>
<ItemTemplate>
<asp:RadioButtonList ID="rbAiredMissed" runat="server"
Enabled="true" OnSelectedIndexChanged="rbAiredMissed_SelectedIndexChanged">

[Code]....

When I select either radiobutton, the event handler did not get triggered.

View 2 Replies

Web Forms :: Common SelectedIndexChanged Event Handler For Multiple RadioButtonList

May 20, 2013

If I have 10 radio button and the value of ten is same 1,0, 2

<asp:RadioButtonList ID="rd_12_a" runat="server" onclick="" RepeatDirection="Horizontal">
<asp:ListItem Value="1">Yes/asp:ListItem>
<asp:ListItem Value="0">no</asp:ListItem>
<asp:ListItem Value="2">other</asp:ListItem>
</asp:RadioButtonList>

So instead of writing if condition for all can i write like this

radiobuttonlist rbl =(radiobuttonlist)sender;
if (rbl.selectedvalue="1" || rbl.selectedvalue="2")

then the javascript modal pop-up will display a message...

View 1 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

AJAX :: RadioButtonList.SelectedIndexChanged Not Raised When The ListItem Has Selected="True" Not Working

Jun 29, 2010

I have two radiobuttons in radiobuttonlist and based on selection, i am enabling and disabling the text box.
First time i used date radiobutton and i took date in corresponding textbox and i saved it into database and then when i came back on same page i saw the date radiobutton is checked has proper value then i clicked on another radiobutton and this time page is postback and clear my all the data which was in my other controls(I have 5-6 text boxed on my page). I dont know why?, It supposed to select my other radiobutton and enable the corresponding text box

[Code]....

if (!Page.IsPostBack)
{
if (gvCredentialTypes.SelectedIndex >= 0)
{
CredentialType credType = CredentialType.FindCredentialType(gvCredentialTypes.SelectedValue.ToString());
if (!String.IsNullOrEmpty(credType.CredentialTypeName)) //If exists, load data
{
String expDays = credType.ExpirationLength.ToString();
DateTime expDate = Convert.ToDateTime(credType.ExpirationDate);
// Assign the value to the controls
LoadExpirationDaysDateValue(expDays, expDate);
}
}
}

private void LoadExpirationDaysDateValue(String expDays, DateTime expDate)
{
// Determines whether value for Days or Date is present
Boolean IsDays = false;
// Check if days value is present
if (String.IsNullOrEmpty(expDays) || expDays.Equals("0"))
{
txtExpirationDays.Text = String.Empty;
}
else
{
txtExpirationDays.Text = expDays;
IsDays = true;
}
if (expDate.ToShortDateString().Equals ("1/1/0001"))
{
txtExpirationDate.Text = String.Empty;
}
else
{
txtExpirationDate.Text = expDate.ToShortDateString();
IsDays = false;
}
// Set the radio button value based on whether Date or Days value is present
if (IsDays)
{
// Get ref to the 1st radio item
ListItem liExpirationInDays = rbExpiration.Items.FindByValue("rbExpirationInDays");
if (liExpirationInDays != null)
{
liExpirationInDays.Selected = true;
rbExpiration.Items.FindByValue("rbExpirationDate").Selected = false;
txtExpirationDate.Text = string.Empty;
txtExpirationDays.Text = expDays;
// Enable or disable the controls based on the radio button selection
txtExpirationDays.Enabled = true;
RequiredFieldValidator1.Enabled = true;
RangeValidator1.Enabled = true;
txtExpirationDate.Enabled = false;
RegularExpressionValidator1.Enabled = false;
CalendarExtender2.Enabled = false;
//compDateValidator.Enabled = false;
RequiredFieldValidator2.Enabled = false;
}
}
else
{
// Get ref to the 2nd radio item
ListItem liExpirationDate = rbExpiration.Items.FindByValue("rbExpirationDate");
if (liExpirationDate != null)
{
liExpirationDate.Selected = true;
rbExpiration.Items.FindByValue("rbExpirationInDays").Selected = false;
txtExpirationDays.Text = string.Empty;
txtExpirationDate.Text = expDate.ToShortDateString();
// Enable or disable the controls based on the radio button selection
txtExpirationDate.Enabled = true;
RegularExpressionValidator1.Enabled = true;
RequiredFieldValidator2.Enabled = true;
CalendarExtender2.Enabled = true;
//compDateValidator.Enabled = true;
txtExpirationDays.Enabled = false;
RequiredFieldValidator1.Enabled = false;
RangeValidator1.Enabled = false;
}
}
}

private void EnableCorrespondingTextbox()
{
switch (rbExpiration.SelectedItem.Value)
{
case "rbExpirationInDays":
txtExpirationDays.Enabled = true;
RequiredFieldValidator1.Enabled = true;
RangeValidator1.Enabled = true;
txtExpirationDate.Text = String.Empty;
txtExpirationDate.Enabled = false;
RegularExpressionValidator1.Enabled = false;
CalendarExtender2.Enabled = false;
RequiredFieldValidator2.Enabled = false;
//compDateValidator.Enabled = false;
break;
case "rbExpirationDate":
txtExpirationDate.Enabled = true;
RegularExpressionValidator1.Enabled = true;
RequiredFieldValidator2.Enabled = true;
CalendarExtender2.Enabled = true;
//compDateValidator.Enabled = true;
txtExpirationDays.Text = String.Empty;
txtExpirationDays.Enabled = false;
RequiredFieldValidator1.Enabled = false;
RangeValidator1.Enabled = false;
break;
}
}

protected void OnSelectedIndexChangedMethod(object sender, EventArgs e)
{
EnableCorrespondingTextbox();
}

View 4 Replies

Vb - Changing Panel Visibility Property On Radiobuttonlist Selection?

Feb 4, 2010

On my .aspx page i want to be able to show and hide certain panels depending on user selections (radiobuttonlists).

For example in my aspx page i have;

[Code]...

But when I try to run the code I get;

"Object reference not set to an instance of an object" on this line If RadioButtonList1.SelectedItem.Equals(3) Then

View 2 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

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

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 :: 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







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