Click here to Skip to main content
15,849,328 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi,

How can I make dropdownlist no postback - I have a dropdownlist which I put a code in selected indexchanged -basically for every indexchanged the code will connect to sql and get values then populate textboxes with values.

here is my code

<asp:DropDownList ID="ddlSalesOrg" runat="server" Style="width: 200px;" AutoPostBack="true" />


Obviously when I remove the autopostback="true" - then indexchanged will not function as expected. Hope you get my question.

thanks..
Posted
Comments
Herman<T>.Instance 12-Sep-11 6:33am    
what do you mean with: 'How can I make dropdownlist no postback' ?
In your example code I do not see the OnSelectedIndexChanged event. Maybe some codebehind to show?
Or do you need a refreshed DropDownList / TextBoxes without a full postback?
In that case use a scriptmanager and an updatepanel around DDL/TB's

Hi,

You Must give auto post back true if u wants to display in dropdown list select ndex changed event
 
Share this answer
 
OnSelectedIndexChanged event will work only if you give AutoPostBack="true".

The AutoPostBack property is used to set or return whether or not an automatic post back occurs when the user presses "ENTER" or "TAB" in the TextBox control.

If this property is set to TRUE the automatic post back is enabled, otherwise FALSE. Default is FALSE.


First you have to understand the basic thing. Check the below article.

http://www.dotnetspider.com/resources/189-AutoPostBack-What-How-works.aspx[^]
 
Share this answer
 
Sorry for the confusion - what im trying to say is - I want to trigger my indexchanged event without postback.. hope i sound clearly now..thanks...
 
Share this answer
 
You cannot trigger OnSelectedIndexChanged with AutoPostBack="false".
Otherwise, you need to call javascript function on the onchange of the Drop Down List.
 
Share this answer
 
Set AutoPostBack = false if you want dropdownlist to no post back
 
Share this answer
 
Comments
Syed Salman Raza Zaidi 12-Sep-11 6:56am    
The OP asked How can I make dropdownlist no postback, thats why i replied this
I notice that this is old but someone looking for the answer might find my comment helpful.

1. Put the control and the textboxes inside an updatepanel.
2. Set
C#
AutoPostBack = true
on the dropdown.
3. Add the dropdown as an async trigger for the updatepanel.
4. at the end of the
C#
onSelectedIndexChanged
update the panel using
C#
panel.Update()
 
Share this answer
 
Comments
Rajesh waran 5-Mar-15 5:07am    
No need to post solution for very old question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900