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
4 1744 Plater 7,872
Recognized Expert Expert
instead ofputting your code in the Page_Load() function, try moxing some into the dropdown1_index changed (or some other similar event) function?
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....
Plater 7,872
Recognized Expert Expert
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
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 exception but it does not save
out the changes either. It seems that upon the postback no data exists in
the dataset. I must be missing something.
...
|
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 i have a button inside and if i click on that button it should open a new page,page2.aspx for me. i do some processing (eg write to a dbase) there and...
|
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
update my database, I am able to get the form fields, and I am able to
replace the data, but when I go "update", the old data remains.
I have done...
|
by: Neo Geshel |
last post by:
This works:
<form>
<asp:TextBox id="name" />
<%= name.ClientID %>
</form>
But this DOES NOT work:
<form>
|
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 browsers and click update it gave me this error:
Specified argument was out of the range of valid values. Parameter name:
| |
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 wanted.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim dsn As String =...
|
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
renaming the duplicate records? My thinking was to take the results of the
duplicate query, and somehow have it number each line where there is a
duplicate...
|
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 there's an error that says: "Syntax error in UPDATE statement."
I wonder what's wrong with my code and how to correct this one?
Below are my codes:...
|
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 update the information which is stored in a SQL database.
In testing we noticed that the form was updating correctly but the update mechanism was also...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |