473,657 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically Creating Controls On A Page

I'm dynamically creating a number of radio buttons on my aspx page based
upon data read from a db. Each radio button has autopostback turned on.
I'm experiencing two problems.

1) I am reading the db, creating the radio buttons, and setting the checked
property (also based upon data in the db) in Page_Load regardless of whether
a postback is occurring or not. The page loads and displays correctly each
time unless the database is updated (say by another program). In this
situation, even though I'm creating the radio buttons and setting their
checked property based on the db, it appears that whatever is in the
viewstate is overriding this process. So, whatever was on the user's screen
before posting back is what gets displayed after the postback regardless of
what is currently in the db. I'd like to know how to overcome this.

2) In this same situation (when the db gets updated) I do get a
CheckedChanged event not only for the change the user made (that caused the
postback to occur) but for any differences between db values and their
corresponding radio button's checked status. This, I suppose, is expected
but is difficult to understand given problem #1. The problem is if I
blindly take each CheckedChanged event and update the db with the current
value of the radio button (as it was on the user's screen) I'll almost
always overwrite changes made by another user. Is the typical approach here
an optimistic locking scheme with a row counter of some type to use to
prevent me from updating "stale" data?

This seems overly complicated, so I assume my approach is wrong. Any help
would be much appreciated. Thanks!
Nov 23 '05 #1
2 1689
Hi,

could you tell me at what stage in the page lifecycle you are loading
your database data. The Viewstate and postback data are loaded in
between the Init and Load stage (signalled by the events). So if you
load your data in the Init stage....

Grtz, Wouter van Vugt
Trainer - Info Support - www.infosupport.com
www.dive-in-it.nl

Nov 23 '05 #2
In Page_Load
"Wouter van Vugt" <wo*****@infosu pport.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com...
Hi,

could you tell me at what stage in the page lifecycle you are loading
your database data. The Viewstate and postback data are loaded in
between the Init and Load stage (signalled by the events). So if you
load your data in the Init stage....

Grtz, Wouter van Vugt
Trainer - Info Support - www.infosupport.com
www.dive-in-it.nl

Nov 28 '05 #3

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

Similar topics

2
4276
by: Duncan Welch | last post by:
Hi, I've got a fairly simple date control, that I'm creating dynamically in my page. The reason for creating it dynamically is that I want the ID to vary, depending on it's situation. The control loads on the page, and the set date is shown. The problem is, when I submit the page, the control doesn't return the date. What am I doing wrong?
4
2494
by: Bas Groeneveld | last post by:
I am developing an ASP.NET application part of which consists of a data entry wizard defined by entries in a data table - ie the controls on each page of the wizard are determined by definitions in the table. I know that I can dynamically add controls (eg a textbox) to the page controls collection of a web form in a server event which will then be rendered onto the form, as in the following snippet: System.Web.UI.WebControls.TextBox...
1
3015
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web page dynamically. To do this, First I including a web page (MainPage.aspx) and I made form tag to Runat=Server. I included one table tag and also made this table Runat=Server side. Second I created three Web User Controls e.g....
1
2569
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web page dynamically. To do this, First I including a web page (MainPage.aspx) and I made form tag to Runat=Server. I included one table tag and also made this table Runat=Server side. Second I created three Web User Controls e.g. wucCustomerInfo.ascx,
2
4560
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is easy, but 1) How do I set about dynamically creating user controls (like TextBox, TextArea) --- simply Declare and initialised (new) the user controls?? How do I "place" it graphically on the form. Ideally, I want them to lay out in a table, one...
3
2535
by: Dotnet Gruven | last post by:
I've built a WebForm with a Table added dynamically in Page_Load when IsPostBack is false. The table includes a couple of TextBoxes, RadioButtonLists and CheckboxLists. On postback, those controls are not present nor their valves in Request.Form.AllKeys.
5
2017
by: SalamElias | last post by:
I am creating several chkBoxes dynamically and assigning an event handler in the Page_load as foillows ***************************** Dim chkCatOption As CheckBox = New CheckBox chkCatOption.Text = rowDS.Item("Option_Item_Desc") chkCatOption.ID = rowDS.Item("ID").ToString chkCatOption.Checked = rowDS.Item("HasOption") chkCatOption.AutoPostBack = True AddHandler chkCatOption.CheckedChanged, AddressOf AddOrUpdate
9
7035
by: netasp | last post by:
hi all, how can I populate one aspx form when page is loading based on page ID? for example: loading page A (to search for VB code) would display labels and texboxes, dropdown lists all related to VB, plus the address bar would show something like this: www.somethinghere?id=3 and if you change number 3 from the address bar to (for example) 34 or 71 you would get different page with the same formatting like I.e: www.somethinghere?id=34...
1
4889
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have set text boxes and labels inside the table rows. I then added a button. All of these are done through code. The problem that i am having is i can get the value from a text box with resides inside the first panel (out side of panel that is...
7
6651
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a tabcontainer which has 1 panel already, however I want to try create the TabPanels dynamically. I followed the advice here: http://www.asp.net/learn/ajax-videos/video-156.aspx (3rd comment - Joe Stagner)
0
8384
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, 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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8820
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8499
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7314
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5630
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.