Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 23rd, 2007, 12:47 PM
rlb rlb is offline
Authorized User
Join Date: Jan 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Radiolist onselectindexchanged not firing

Hello i've come across a peculiar thing here, i don't understand whats going on.

Here is my webpage :

<%@ Page Language="C#" MasterPageFile="~/mymaster.master" AutoEventWireup="true" CodeFile="Advising.aspx.cs" Inherits="Advising_Default" Title="Advising Webpage" %>

<asp:Content ID="Content2" ContentPlaceHolderID="PageContent" Runat="Server">
<table width="100%"><tr><td>
Student Name : <asp:TextBox runat="server" ID="StudentName" />
</td><td width="200">
<asp:RadioButtonList ID="StudentType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="StudentType_SelectedIndexChanged">
<asp:ListItem Text="Undergraduate Student" Selected="true"  />
<asp:ListItem Text="Graduate Student" />
Advising Type : <asp:DropDownList runat="server" ID="choose_AdvisingType" />
Degree : <asp:DropDownList runat="server" ID="choose_AdvisingDegree" />
</tr><tr><td colspan="3">
<br />
Additional Description : <asp:TextBox runat="server" ID="AdditionalDescription" TextMode="multiLine" Width="80%" />
And here is my codebehind for that page :
public partial class Advising_Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsPostBack)

    protected void StudentType_SelectedIndexChanged(object sender, EventArgs e)

    private void populateDropDowns(){
        //populates the two ddls based on the radiolist selecteditem
        if(StudentType.SelectedItem.Value.Equals("Undergraduate Student")){

        } else if(StudentType.SelectedItem.Value.Equals("Graduate Student")){

public void loadRecord(int instructionID)
        Instruction_Advising_Data data = bll.loadRecord(instructionID);
        StudentName.Text = data.StudentName;
        AdditionalDescription.Text = data.AdditionalInfo;
        //choose grad/undergrad
            //StudentType.Items.FindByText(data.StudentType).Selected = true;
        } catch { /* do nothing*/ }
        //populate the drop downs accordingly


Okay, so this page works fine and dandy, everything as it should with the code above That is, when the user selects a different radiobutton value, the dropdown values change.

But as soon as I try to set the radio list's selected value myself (ie uncomment the line in red : StudentType.Items.FindByText(data.StudentType).Sel ected = true; ), the page does not work properly. The autopostback doesnt happen nor is the StudentType_SelectedIndexChanged() event fired. Looking at the page source, one can see that the javascript wireup for the selectindexchanged event isn't even hooked up.

Whats going on and how can I fix my code so that I can set the selecteditem in my codebehind and still have my postback events fire that changes the ddls ?
Old May 23rd, 2007, 01:46 PM
rlb rlb is offline
Authorized User
Join Date: Jan 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts

duh this fixes it
StudentType.Items.FindByText(data.StudentType).Sel ected = true;

happy coding

Similar Threads
Thread Thread Starter Forum Replies Last Post
CheckboxList onselectindexchanged rlb ASP.NET 2.0 Professional 1 August 13th, 2008 12:56 PM
Event Firing tobriain C# 1 June 12th, 2007 08:19 AM
Events not firing in IE malk ASP.NET 1.0 and 1.1 Professional 7 August 29th, 2006 01:32 PM
Firing Blanks... ozPATT Access VBA 11 January 20th, 2006 11:26 AM
Mysql not firing up ricbenson MySQL 1 February 6th, 2005 07:05 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.