473,498 Members | 1,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropdownlist postback not firing

Sorry to repost, but please see below... this is driving me mad at
this point.

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

Mar 5 '07 #1
5 10474
Howdy,
Show us how you bind the data. It seems you rebind data on every postback.
--
Milosz
"Gearóid" wrote:
Sorry to repost, but please see below... this is driving me mad at
this point.

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

Mar 5 '07 #2
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:
Sorry to repost, but please see below... this is driving me mad at
this point.

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

Mar 5 '07 #3
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;
}

Mar 5 '07 #4
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:
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;
}

Mar 5 '07 #5
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
Mar 5 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3028
by: Shiju Poyilil | last post by:
Hi ! I have a requirement wherein i am binding a datalist which contains a label (Caption for the field) and some literal hidden fields and a dropdown list. When I am binding to the datalist.....
1
4396
by: Paul L | last post by:
Hi, I have an issue with the OnSelectedIndexChanged event not firing for a DropDownList control which is in the ItemTemplate of a DataList. I have made an exact copy of the DropDownList control,...
11
5786
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
1
7198
by: Jason Wilson | last post by:
I have two dropdownlists that are bound to the same datasource and I have a couple of questions: 1) Because they are bound to the same datasource, I am assuming that they only make 1 round trip...
2
3277
by: jnoody | last post by:
The problem I am having is with the SelectedIndexChanged event not always firing or the SelectedIndex property not being correct when the event does fire. The code is below, but here are some...
7
12046
by: Damien | last post by:
Hi guys, I'm trying to learn ASP.NET and got a problem with DroDownList... SelectedIndexChanged doesn't fire. Maybe you'll be able to suggest something. I think it may be connected with the...
1
1555
by: =?iso-8859-1?B?R2VhcvNpZA==?= | last post by:
Hi, Wierd problem. Using ASP.NET 2.0. Have a DropDownList - <asp:DropDownList ID="DropDownListMake" runat="server" CssClass="selectComparison" AutoPostBack="True"...
3
10557
by: Lohboy | last post by:
Using ASP.NET and IE7. (Sorry if I am posting in the wrong forum but my problem seemed to be more related to the JavaScript side than the ASP.NET side.) I have two DropDownList controls the...
2
3726
by: MattB | last post by:
I have a (.Net 1.1) form with a Repeater and a DropDownList in the ItemTemplate. I programmatically make the DDL Autopostback = true at runtime based on the bound data. That works - I can see the...
4
1447
by: Waldy | last post by:
Hi there, I have a web form with some DropDownList controls that I am trying to trap the selection change and run the attached server code. However, even thought the controls have the runat...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7208
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4915
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4593
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3095
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.