473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Autopostback, binding and losing selection

Hi-

I'm a bit rusty cause it's been awhile since I've made an asp.net app, but
here is what I want to do:

single aspx page
bound DropDownList w/ autopost back that holds names of customers
DataGrid that shows customer data

When a user selects a customer from the drop down, I get the selected
value(customer ID) and store it into a member variable (mCustId) then I call
my BindData() method that uses that CustId to filter a DataTable and show
the correct data for that customer.

Everything works except when the Autopostback fires, I don't have the
correct selection in the DropDownList. This is because I'm calling
BindData() which also binds the DropDownList.

The problem is obvious and a basic solution is also obvious (call separate
function just to bind the grid) but this does not seem like a very flexible
solution. Is there some way to make the DropDownList's selectedItem value
persist?

Based on what I have described here(this MUST be a common approach) what is
the standard way to handle this?

Thanks for any tips or help!
Steve
Nov 18 '05 #1
2 1603
There is no way to do like your describing.
You should not bind again the dropdownlist in the postback event.

I'm a bit rusty cause it's been awhile since I've made an asp.net app, but
here is what I want to do:

single aspx page
bound DropDownList w/ autopost back that holds names of customers
DataGrid that shows customer data

When a user selects a customer from the drop down, I get the selected
value(customer ID) and store it into a member variable (mCustId) then I call my BindData() method that uses that CustId to filter a DataTable and show
the correct data for that customer.

Everything works except when the Autopostback fires, I don't have the
correct selection in the DropDownList. This is because I'm calling
BindData() which also binds the DropDownList.

The problem is obvious and a basic solution is also obvious (call separate
function just to bind the grid) but this does not seem like a very flexible solution. Is there some way to make the DropDownList's selectedItem value
persist?

Based on what I have described here(this MUST be a common approach) what is the standard way to handle this?

Thanks for any tips or help!
Steve

Nov 18 '05 #2
OK, thanks for the response. Atleast I know I'm not missing anything now ;)
"SHENG333" <wh********@untsoft.com.cn> wrote in message
news:ea**************@TK2MSFTNGP12.phx.gbl...
There is no way to do like your describing.
You should not bind again the dropdownlist in the postback event.

I'm a bit rusty cause it's been awhile since I've made an asp.net app, but here is what I want to do:

single aspx page
bound DropDownList w/ autopost back that holds names of customers
DataGrid that shows customer data

When a user selects a customer from the drop down, I get the selected
value(customer ID) and store it into a member variable (mCustId) then I

call
my BindData() method that uses that CustId to filter a DataTable and show the correct data for that customer.

Everything works except when the Autopostback fires, I don't have the
correct selection in the DropDownList. This is because I'm calling
BindData() which also binds the DropDownList.

The problem is obvious and a basic solution is also obvious (call separate function just to bind the grid) but this does not seem like a very

flexible
solution. Is there some way to make the DropDownList's selectedItem value persist?

Based on what I have described here(this MUST be a common approach) what

is
the standard way to handle this?

Thanks for any tips or help!
Steve


Nov 18 '05 #3

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

Similar topics

1
by: Null | last post by:
Hello -- Is there a way to prevent the autopostback of a drop down list if there is a "default" item in the list -- example, a drop down list where the first item says "Select One" and the...
3
by: Lloyd Sheen | last post by:
I have a page that works fine. I am trying to optimize the page by overriding some of the Information that is being saved in the hidden VIEWSTATE. If I make the properties of the dropdown False...
8
by: Matthew Louden | last post by:
why need to set autopostback property to be true?? I know autopostback event means to send the form to the server automatically. I tried checkbox, checkbox list, radio button, and radio button...
0
by: Jaleel Syed via .NET 247 | last post by:
Hi, I have a Search page, which has a Search Button which whenclicked, Binds a DataGrid to the Data returned from Search(whichimplies that I am not Binding the Grid in Page_Load method). Inthe...
5
by: Mani | last post by:
Hi, Is there any other way to quickly grab the selected index/value of a dropdownlist other using than the autopostback property to true? ... I found the autopostback to slow down things.... in...
3
by: Tina | last post by:
I have a grid with a select button. I went to turn off AutoPostBack and there is no such attribute. Is there any way to make a grid behave as would a listbox and not autopost back upon the...
2
by: rdb | last post by:
VB.NET web program with a webform w/2 dropdownlistboxes, set to AutoPostBack TRUE, selection in either dropdown fires the SelectedIndexChanged events correctly UNTIL I navigate to second webform in...
3
by: trialproduct2004 | last post by:
hi all i am new to asp.net can some one tell me use of autopostback of dropdownlist. When i set this property to true my selectionchanged event is getting fired. but when this property is set to...
1
by: pleaseexplaintome | last post by:
I have a datagrid with checkboxes and I can check/uncheck the checkboxes to update a database by calling my oncheckchanged function. I would like to add popup asking the users if they are sure...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
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...

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.