Connecting Tech Pros Worldwide Help | Site Map

dropdownlist postback not firing

  #1  
Old March 5th, 2007, 11:25 AM
=?iso-8859-1?B?R2VhcvNpZA==?=
Guest
 
Posts: n/a
Sorry to repost, but please see below... this is driving me mad at
this point.

http://groups.google.com/group/micro...a7318a2f318442

  #2  
Old March 5th, 2007, 11:55 AM
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
 
Posts: n/a

re: dropdownlist postback not firing


Howdy,
Show us how you bind the data. It seems you rebind data on every postback.
--
Milosz


"Gearóid" wrote:
Quote:
Sorry to repost, but please see below... this is driving me mad at
this point.
>
http://groups.google.com/group/micro...a7318a2f318442
>
>
  #3  
Old March 5th, 2007, 12:05 PM
=?Utf-8?B?QWRsYWkgTWFzY2hpYWNo?=
Guest
 
Posts: n/a

re: dropdownlist postback not firing


Strange

I have tried the following

<asp:DropDownList ID="DropDownListMake" runat="server"
CssClass="selectComparison" AutoPostBack="True"
OnSelectedIndexChanged="DropDownListMake_SelectedI ndexChanged" >
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>

--------

protected void DropDownListMake_SelectedIndexChanged(object
sender,EventArgs e)
{
int x ;

if (!DropDownListMake.SelectedIndex.Equals("-1"))
x = Int32.Parse(DropDownListMake.SelectedValue);
}

--------

and it did work
perhaps the AutoPostBack="True"
doesn't fire if the DDL isn't bound to any data

-------------------------------------------
If my answer helped you please press "Yes" bellow

Adlai Maschiach
http://blogs.microsoft.co.il/blogs/adlaim/


"Gearóid" wrote:
Quote:
Sorry to repost, but please see below... this is driving me mad at
this point.
>
http://groups.google.com/group/micro...a7318a2f318442
>
>
  #4  
Old March 5th, 2007, 12:25 PM
=?iso-8859-1?B?R2VhcvNpZA==?=
Guest
 
Posts: n/a

re: dropdownlist postback not firing


The bizarre thing is the AutoPostBack="True" does fire. If I place a
breakpoint in my code on the Page_Load it is hit after I select
something in the DropDownList. But when it hitsthe line to see if
it's a postback or not it says it isn't. If I hover over if(!
this.IsPostBack) it tells me IsPostBack is false.

So even the the postback has fired and the breakpoint has been
triggered in my Page_load method, it thinks it's not a postback.
That's what baffles me...

snippet of Page_Load to bind data...

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
LoadMakes();
}
else // postback
{
nMakeID = int.Parse(DropDownListMake.SelectedValue);
}
}


private void LoadMakes()
{
DataTable dtMakes = new NewBike().GetMakes("Bike");

ClearDropDowns(true, true);
PopulateDropDown(DropDownListMake, dtMakes, "makeid", "makename",
"Make");
}

private void PopulateDropDown(DropDownList ddlList, DataTable dtData,
string strValueField, string strTextField, string strDefaultPromt)
{
ddlList.DataSource = dtData;
ddlList.DataValueField = strValueField;
ddlList.DataTextField = strTextField;
ddlList.DataBind();
ddlList.Items.Insert(0, new ListItem("Choose " + strDefaultPromt,
"-1"));
ddlList.SelectedIndex = 0;
}

  #5  
Old March 5th, 2007, 12:45 PM
=?Utf-8?B?QWRsYWkgTWFzY2hpYWNo?=
Guest
 
Posts: n/a

re: dropdownlist postback not firing


Hi

each time you populate a DDL ( or every other control )
it's previous ViewState is Cleared/Ignored
that may be the cause for that
the SelectedIndexChange isn't fired
becuse according to the Page the contence has
change , thus irrelevant ( even if it's contence is the same )

-------------------------------------------


If my answer helped you please press "Yes" bellow

Adlai Maschiach
http://blogs.microsoft.co.il/blogs/adlaim/


"Gearóid" wrote:
Quote:
The bizarre thing is the AutoPostBack="True" does fire. If I place a
breakpoint in my code on the Page_Load it is hit after I select
something in the DropDownList. But when it hitsthe line to see if
it's a postback or not it says it isn't. If I hover over if(!
this.IsPostBack) it tells me IsPostBack is false.
>
So even the the postback has fired and the breakpoint has been
triggered in my Page_load method, it thinks it's not a postback.
That's what baffles me...
>
snippet of Page_Load to bind data...
>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
LoadMakes();
}
else // postback
{
nMakeID = int.Parse(DropDownListMake.SelectedValue);
}
}
>
>
private void LoadMakes()
{
DataTable dtMakes = new NewBike().GetMakes("Bike");
>
ClearDropDowns(true, true);
PopulateDropDown(DropDownListMake, dtMakes, "makeid", "makename",
"Make");
}
>
private void PopulateDropDown(DropDownList ddlList, DataTable dtData,
string strValueField, string strTextField, string strDefaultPromt)
{
ddlList.DataSource = dtData;
ddlList.DataValueField = strValueField;
ddlList.DataTextField = strTextField;
ddlList.DataBind();
ddlList.Items.Insert(0, new ListItem("Choose " + strDefaultPromt,
"-1"));
ddlList.SelectedIndex = 0;
}
>
>
  #6  
Old March 5th, 2007, 01:15 PM
=?iso-8859-1?B?R2VhcvNpZA==?=
Guest
 
Posts: n/a

re: dropdownlist postback not firing


Thanks for your help. I got this sorted.

I have the following method

protected override object LoadPageStateFromPersistenceMedium()
{

LosFormatter Format = new LosFormatter();
//return Format.Deserialize (Request.Form["__VIEWSTATE"]);
string strSession = "";

if (Session["_ViewState"] != null)
{
strSession = Session["_ViewState"].ToString();
return Format.Deserialize(strSession);
}
else
{
return null;
}
}

This was being called in a basepage. Before it was called the
postback was there, but after it executed it was lost. It appears
this was clearing my viewstate, and in turn losing my postback


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownList in a Repeater - OnSelectedIndexChange not firing MattB answers 2 October 1st, 2007 09:55 PM
dropdownlist postback not firing =?iso-8859-1?B?R2VhcvNpZA==?= answers 1 March 5th, 2007 02:15 PM
OnSelectedIndexChanged event not firing on a DropDownList within a DataList Paul L answers 1 November 19th, 2005 11:12 AM
Help w/AddHandler (Not Firing Off) Jeffrey A. Voigt answers 3 November 17th, 2005 08:18 PM