472,991 Members | 2,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Update & Database Access Using IsPostBack

12
Hi, I have an ASP.NET 2.0 C# issue that has been troubling me for some time, and if someone could shed some light on this I would appreciate it.

This seems to be a commonly themed question, although most relate to DataGrids and this is a slightly different scenario.

This is completely hypothetical, but say I have a form for editing database information.

This form contains two drop down boxes, one of which determines the content of the other. The problem is that in order for the second drop down box to be updated on the autopostback of the first, it needs to be out with the !IsPostback section. However, if I do this then I cannot add it's details to the database when I submit the form using an event handler.

e.g.

if (!IsPostBack)
{
Drop Down List 1 // This has autopostback set so that when I choose a value it populates Drop Down List 2
}

Drop Down List 2 // This is outside the !IsPostback section so updates when Drop Down Box 1 changes, but wont allow the selected value to be updated by the submit event handler.

Event Handler // Submit values to database.

This seems to be caused by the fact that the page is reinitialised before the new values can be entered into the Database. The database therefore is updated with the old values.

I can ensure the second Drop Down Box is updated by including it in the !IsPostBack section but if I do this, then it's value will not obviously be updated when the value of the first Drop Down Box is changed.

Although this is a hypothetical situation, I have had this problem in many different similar scenarios. I want the ability to Edit & Dynamically change! :) Ian
May 23 '07 #1
4 1714
Plater
7,872 Expert 4TB
instead ofputting your code in the Page_Load() function, try moxing some into the dropdown1_indexchanged (or some other similar event) function?
May 23 '07 #2
gihope
12
That's interesting. So instead of using autopostback, use the index changed event to make a call to the database and potentially databind the second drop down box.

I'm not sure that's possible without refreshing the page, but its worth a try....
May 23 '07 #3
Plater
7,872 Expert 4TB
you would still need the autopostback set.
BUT the data would only be changed on the specific postbacks that relate to the index being changed
May 23 '07 #4
gihope
12
Plater I haven't been able to put this into place, because I've been caled off on a development project.

But I wanted to write and say thank you very much for taking the time to consider and reply to my post. Regards, Ian
May 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ray Valenti | last post by:
In a .Net Asp application I am able to retrieve data from an Access db and display in on a web form. How ever during the update function after a page update, the update command does not throw an...
1
by: radha | last post by:
hi friend Could somebody please tell me how to update an access record having two primary keys?(vb.net, asp.net, access Also how do we show a page from another page,for eg i am in page1.aspx and...
4
by: René Kabis | last post by:
People, I am at my wit's end. I am using the exact code from http://aspnet.4guysfromrolla.com/articles/071002-1.aspx And yet, the code does not manage to update the database. When I go to...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
1
by: mursyidatun ismail | last post by:
Dear all, database use: Ms Access. platform: .Net i'm trying to update a record/records in a table called t_doctors by clicking da edit link provided in the database. when i ran through da...
3
by: virlinz | last post by:
Hello I'm a newbie who has a problem with updating the dataset into the database. Maybe I missed a few lines of codes. Please shed some light for me. The following code is working but not like I...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
2
tjc0ol
by: tjc0ol | last post by:
Hi guys, Im just wondering that I cannot update my database throught datagrid datalist control, and the only thing works is that I can delete, cancel, edit but when I clicked update link...
2
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.