Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 January 6th, 2005, 01:42 PM
Registered User
 
Join Date: Jan 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default postback issue with drop downlists

I have a problem with which I am struggling for many days.
I have a page which has six drop down list (which are webform elements and not html elements). Auto postback property is enabled for all the elements. The data in the dropdown lists are related in a hierarical fashion. Now to give you the general idea of the working of the page, suppose, When the client changes the selection in any of lists in the page (say list number 2), it updates the items of the subsequent lists (that is lists 3, 4, 5, 6). The process is database intensive, so it takes quite a while before any results comes up.
What I want is to prevent the client from changing the selection before their previous request is serviced, by disabling the dropdown lists in the page.
I am trying to use Javascript to disable the lists by adding a "OnChange" attribute to the dropdown list, in the Page_Load event of the page.
            ddllist1.Attributes.Add("OnChange", "disable();")
            ddllist2.Attributes.Add("OnChange", "disable();")
        ...........
            ddllist6.Attributes.Add("OnChange", "disable();")
The disable function is defined on the <Head> of the aspx page. Now the trouble is, this "OnChange" event is suppressing the "OnSelectedIndexChanged" event of the dropdown lists!! So though the lists are getting disabled, when the client is changing the selection, the code in the "OnSelectedIndexChanged" is not executing and the lists are not getting updated.
Please suggest.


 
Old January 6th, 2005, 11:26 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I have seen similar problems to this. It has to do with the way the form is processed. When you disable the dropdownlist, the value for it never get's posted to with the form data. So what you need to do is disable it with a time delay. Modify your disable() JS function to do something like this:

setTimeout("<put current disable code in here>", 100);

Or you could modify the server side code like so:

ddllist1.Attributes.Add("OnChange", "setTimeout('disable()', 100);")

Either way, your onChange event handler will return before the DDL is disabled and the onchange autopostback call will happen with useful data, then after the 100 millisecond delay, the DDLs will be disabled. Usually this is quite suitable to let the post fire off before the use has a chance to try clicking again.
 
Old January 7th, 2005, 01:23 PM
Registered User
 
Join Date: Jan 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello planoie,
You tip saved my day. You are great.


thanks

 
Old March 26th, 2005, 01:36 PM
Registered User
 
Join Date: Dec 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello emachines,

There is a way of making this faster without having to go to the database everytime on each selectedIndexchanged event

Get the contents of all the ddls as separate tables in a dataset.

In the dataset, create a relation between a column of one table to the same column of another table.

This way you do not have to go to the database, because it is very resource-intensive.

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
ajax drop downlists msathyaprasad90 ASP.NET 1.0 and 1.1 Professional 1 June 28th, 2006 02:54 AM
drop down with large data on postback gives error madhusrp ASP.NET 1.0 and 1.1 Professional 5 March 16th, 2006 02:55 AM
postback issue with drop downlists with javascript emachines Javascript 3 January 24th, 2005 06:54 AM
postback issue with drop downlists emachines General .NET 1 January 9th, 2005 09:42 PM
postback issue with drop downlists with javascript emachines Javascript How-To 1 January 6th, 2005 01:49 PM





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