Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 23rd, 2007, 12:47 PM
rlb rlb is offline
Authorized User
 
Join Date: Jan 2007
Location: , , .
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 :

Code:
<%@ 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" />
</asp:RadioButtonList>
</td><td>
Advising Type : <asp:DropDownList runat="server" ID="choose_AdvisingType" />
</td><td>
Degree : <asp:DropDownList runat="server" ID="choose_AdvisingDegree" />
</td>
</tr><tr><td colspan="3">
<br />
Additional Description : <asp:TextBox runat="server" ID="AdditionalDescription" TextMode="multiLine" Width="80%" />
</td></tr></table>
....
And here is my codebehind for that page :
Code:
public partial class Advising_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            populateDropDowns();
            loadRecord(instructionID);
        }
    }

    protected void StudentType_SelectedIndexChanged(object sender, EventArgs e)
    {
        populateDropDowns();
    }

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

        } else if(StudentType.SelectedItem.Value.Equals("Graduate Student")){
            bll.fillGradAdvisingTypes(choose_AdvisingType);
            bll.fillGradDegrees(choose_AdvisingDegree);
        }
    }

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

    }

...
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 ?
  #2 (permalink)  
Old May 23rd, 2007, 01:46 PM
rlb rlb is offline
Authorized User
 
Join Date: Jan 2007
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

happy coding
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:12 AM.


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