Question on DropDownList

J

Jason

Dear All,
I have a question in dropdownlist

(aspx)
<asp:dropdownlist id="ddonLeaveType" runat="server" CssClass="pullDown"
AutoPostBack="True"
OnSelectedIndexChanged="ddonLeaveType_SelectedIndexChanged">
(in code behide)
public void ddonLeaveType_SelectedIndexChanged(object sender,
System.EventArgs e)
{
initLeaveType = Int32.Parse(this.ddonLeaveType.SelectedItem.Value);
}

but no action after the selected index changed
why??
please help
 
G

Guest

Just try this

public void ddonLeaveType_SelectedIndexChanged(object sender
System.EventArgs e) handles ddonLeaveType.SelectedIndexChange

----- Jason wrote: ----

Dear All
I have a question in dropdownlis

(aspx
<asp:dropdownlist id="ddonLeaveType" runat="server" CssClass="pullDown
AutoPostBack="True
OnSelectedIndexChanged="ddonLeaveType_SelectedIndexChanged"
(in code behide
public void ddonLeaveType_SelectedIndexChanged(object sender
System.EventArgs e

initLeaveType = Int32.Parse(this.ddonLeaveType.SelectedItem.Value)


but no action after the selected index change
why?
please hel
 
N

nvraman19

public void ddonLeaveType_SelectedIndexChanged(object sender,
System.EventArgs e) handles Objectname.eventname
should be there.
Correct it. This will work fine.
Regards,
N.Venkat
 
D

devplayer04

you only pass the current value to the initLeaveType... that;s all
what are you expecting?

also, I tend to code along the following lines:

/// centralised SelectedIndexChanged event for all listcontrols
/// makes it easier to check up on what's happening:
/// just my own opinion anyways.
public void ListControl_SelectedIndexChanged(object sender, System.EventArgs
e)
{
ListControl control = sender as ListControl;
if (control != null)
{
/// logic
switch (control.ID)
{
case "ddonLeaveType":
///example only:
ProcessLeaveType(int.Parse(control.SelectedItem.Value));
break;
case "someotherList":
/// example only:
DoSomethingElse();
break;
}
}
}

private void ProcessLeaveType(int value)
{
/// do something
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top