473,785 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple user conrols on a web form

I have been stuck on this for some time and am desperate for a solution. I run into this all of the time! I will give a over simplified example to illustrate the problem. Say you have 2 user controls on a web form. One for inputing data (like a line item to an order) and one to display the detail data (a data grid with all line items the order). So, you input data into the input form, then click the add button. The from in posted back. Naturally you would want the newly added line to show up in the detail user control when the form is refreshed. The problem is it probably will not. Why? Because the event handler for the add button will be called after the data grid (or repeater whatever) has been bound (Assuming you are doing the data binding for the grid in the Page_Load event handler of the detail control). So basically the detail grid is created and THEN the line is added. In this simple situation you could probably work around it (Response.Redir ect back to itself but then you loose view state which in undesirable). As you can imagine the problem gets quite complicated when you have many many user controls on a page. What is the answer to this? Is my architecture fundamentally flawed and this structure is no good? HELP!
Nov 18 '05 #1
3 1389
Sam, when you want an update event to affect the output, put the output in
Page Prerender (happens after the event is processed) instead of Page Load
(happens before the event is processed, as you know). Check out this article:
http://dotnetjunkies.com/tutorial/b8...9f4c739bc.dcik

Bill

"Sam Kuehn" wrote:
I have been stuck on this for some time and am desperate for a solution. I run into this all of the time! I will give a over simplified example to illustrate the problem. Say you have 2 user controls on a web form. One for inputing data (like a line item to an order) and one to display the detail data (a data grid with all line items the order). So, you input data into the input form, then click the add button. The from in posted back. Naturally you would want the newly added line to show up in the detail user control when the form is refreshed. The problem is it probably will not. Why? Because the event handler for the add button will be called after the data grid (or repeater whatever) has been bound (Assuming you are doing the data binding for the grid in the Page_Load event handler of the detail control). So basically the detail grid is created and THEN the line is added. In this simple situation you could probably work around it (Response.Redir ect back to itself but then you loose view state which in undesirable). As you can imagine the problem gets quite complicated when you have many many user controls on a page. What is the answer to this? Is my architecture fundamentally flawed and this structure is no good? HELP!

Nov 18 '05 #2
The solution is easy, and you have two options. First, when the click event
of the user control fires, add the row then call a "rebind" method from the
other user control to rebind the data, something like:

public class detailData
public Page_Load
if not page.ispostback then
RebindData()
end if
end
public RebindData
datalist.DataSo ure = GetData()
datalist.DataBi nd
end
...
end class
public class MainPage
public details as detailData 'user control has an id of "details"
obviously
...
end class

public class InputData
public OnClick
AddNewData()
Ctype(Page, MainPage).detai ls.RebindData()
end
..
end class
A much better solution is to have InputData raise an event which detailData
can listen to and rebind itself...You can find out more about these at:
http://openmymind.net/communication/index.html

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Sam Kuehn" <sa******@hotma il.com> wrote in message
news:u5******** ******@TK2MSFTN GP09.phx.gbl...
I have been stuck on this for some time and am desperate for a solution.

I run into this all of the time! I will give a over simplified example to
illustrate the problem. Say you have 2 user controls on a web form. One
for inputing data (like a line item to an order) and one to display the
detail data (a data grid with all line items the order). So, you input data
into the input form, then click the add button. The from in posted back.
Naturally you would want the newly added line to show up in the detail user
control when the form is refreshed. The problem is it probably will not.
Why? Because the event handler for the add button will be called after the
data grid (or repeater whatever) has been bound (Assuming you are doing the
data binding for the grid in the Page_Load event handler of the detail
control). So basically the detail grid is created and THEN the line is
added. In this simple situation you could probably work around it
(Response.Redir ect back to itself but then you loose view state which in
undesirable). As you can imagine the problem gets quite complicated when
you have many many user controls on a page. What is the answer to this? Is
my architecture fundamentally flawed and this structure is no good? HELP!
Nov 18 '05 #3
Great Aricatle thanks! I have began implamenting the soltion in the aritcale.
The solution is easy, and you have two options. First, when the click
event of the user control fires, add the row then call a "rebind"
method from the other user control to rebind the data, something like:

public class detailData
public Page_Load
if not page.ispostback then
RebindData()
end if
end
public RebindData
datalist.DataSo ure = GetData()
datalist.DataBi nd
end
...
end class
public class MainPage
public details as detailData 'user control has an id of "details"
obviously
...
end class
public class InputData
public OnClick
AddNewData()
Ctype(Page, MainPage).detai ls.RebindData()
end
..
end class
A much better solution is to have InputData raise an event which
detailData can listen to and rebind itself...You can find out more
about these at: http://openmymind.net/communication/index.html

Karl

"Sam Kuehn" <sa******@hotma il.com> wrote in message
news:u5******** ******@TK2MSFTN GP09.phx.gbl...
I have been stuck on this for some time and am desperate for a
solution.

I run into this all of the time! I will give a over simplified example
to illustrate the problem. Say you have 2 user controls on a web
form. One for inputing data (like a line item to an order) and one to
display the detail data (a data grid with all line items the order).
So, you input data into the input form, then click the add button.
The from in posted back. Naturally you would want the newly added line
to show up in the detail user control when the form is refreshed. The
problem is it probably will not. Why? Because the event handler for
the add button will be called after the data grid (or repeater
whatever) has been bound (Assuming you are doing the data binding for
the grid in the Page_Load event handler of the detail control). So
basically the detail grid is created and THEN the line is added. In
this simple situation you could probably work around it
(Response.Redir ect back to itself but then you loose view state which
in undesirable). As you can imagine the problem gets quite
complicated when you have many many user controls on a page. What is
the answer to this? Is my architecture fundamentally flawed and this
structure is no good? HELP!


Nov 18 '05 #4

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

Similar topics

2
3155
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as they want. If they need to add more, they click an "add name" button and the javascript inserts another row of input boxes. Each row should have two radio buttons to indicate sex (M F). When you have multiple text input boxes with the same...
12
8884
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
4
4042
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a form with multiple pages on it. There is one text field on the third page of the form that I need the user to complete before leaving the form or moving to the next record. So, in the BeforeUpdate event of the form itself I have the following code:
0
2703
by: misscrf | last post by:
I am currently working on a database, in 3rd normal form, which is for candidates who apply for a job with the law firm that I workd for. My issue is with good form design. I have a main form. Then I have 3 pages on a tab control ( 4 if the type of candidate validates that is is to be shown) Each page has a subform. The subforms can be either single or continuous, I think I am still deciding what I want to lock down this entry...
4
6956
by: John | last post by:
Hi all, I'm having a little problem understanding the concepts of dynamically loading/unloading user conrols: 1. If I have a couple of usercontrols embedded within a few tables cells on my page, setting the usercontrol's visible to false still fires the Page_Load event. Isn't this unnecessary overhead when it doesn't even show in my page.
3
3048
by: Pint | last post by:
I have a simple web user control. I'd like for this form to appear twice on a single aspx page. How do I get around the problem of having more than one <form runat=server> tag? More background: the user control is a login box. For design reasons I want the box to be available in the header as well as the bottom of the page. Thanks, Pint
3
3036
by: C | last post by:
Hi, I have a User Control (.ascx) which has links to all the ASPX Pages that exist in my application. This User Control is used on all my ASPX's. I am havinga problem with the paths in my ASCX. If I click on a link from an ASPX page on the root of the project it works
7
15662
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is there an equivalent property for the DataGridView? I have searched, but have not found one. I would like the user to be able to see all the columns of the table on one screen - thus eliminating the need to use the horizontal scroll bar to view...
5
3311
by: Neil | last post by:
"lyle" <lyle.fairfield@gmail.comwrote in message news:48c3dde7-07bd-48b8-91c3-e157b703f92b@f3g2000hsg.googlegroups.com... Question for you. I'm doing something similar, only, instead of opening the forms all at once, I'm opening them as needed. I have a main form with multiple records; and then I have a pop-up form that the user opens with button. The pop-up form contains one record relating to the current record in the main form (but...
0
9645
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
9481
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
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...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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
9953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8978
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
5383
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
4054
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

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.