473,769 Members | 5,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple user controls on the same page

Hello,

I have a a web form where i dynamically load a user control. The web
page is an issue log, and each user control I add is a specific issue.
I load them as follows:

Try

sqlConn.Open()

With sqlCmd
.CommandType = CommandType.Sto redProcedure
.CommandText = "sp_s_Issue s"
.Parameters.Add (New
SqlClient.SqlPa rameter("@Clien tTaskID", CType(Page,
DMSPageBase).Ta sk.ClientTaskID ))
.Connection = sqlConn
End With

sqlAdapter.Sele ctCommand = sqlCmd
sqlAdapter.Fill (sqlSet)

x = 1

For Each row In sqlSet.Tables(0 ).Rows
ILD = LoadControl("is suelog_detail.a scx")

ILD.sqlConn = sqlConn
ILD.LoadIssueDa ta(row)
ILD.ID = "IssueLog_" & x

pnlIssues.Contr ols.Add(ILD)
x = x + 1

Next

Finally
sqlConn.Close()
End Try

This works great. All the issue log detail show up. The user control
has a button which allows someone to add a comment about the issue.
This works fine on the first control. The comment gets added no
problem. If I try to add a comment to the second user control, the
comment actually gets added to the first user control (the comment gets
added to the database with the ID of the first issue control). I
checked each command button and they do have different IDs:

_ctl1_IssueLog_ 1_cmdAddComment
_ctl1_IssueLog_ 2_cmdAddComment
_ctl1_IssueLog_ 3_cmdAddComment

The problem is that the event handler is messing up. If I press the
second command button, the event for the first command button fires.
When I debug, if I press the second button, I have a break point in the
command button handler. When it breaks I look at the issue ID and it's
the ID of the first issue, not the second. The event handler always
seems to be calling the first user controls procedure.....

Can comeone please help? Thanks!

Jul 5 '06 #1
2 2601
For Each row In sqlSet.Tables(0 ).Rows
ILD = LoadControl("is suelog_detail.a scx")

ILD.sqlConn = sqlConn
ILD.LoadIssueDa ta(row)
ILD.ID = "IssueLog_" & x

pnlIssues.Contr ols.Add(ILD)
x = x + 1

Next
Does it work if you use:

For Each row In sqlSet.Tables(0 ).Rows
Dim ILD as new issuelog_detail () ' Or whatever your control's class is
called

Jul 5 '06 #2

Leon Mayne wrote:
For Each row In sqlSet.Tables(0 ).Rows
ILD = LoadControl("is suelog_detail.a scx")

ILD.sqlConn = sqlConn
ILD.LoadIssueDa ta(row)
ILD.ID = "IssueLog_" & x

pnlIssues.Contr ols.Add(ILD)
x = x + 1

Next

Does it work if you use:

For Each row In sqlSet.Tables(0 ).Rows
Dim ILD as new issuelog_detail () ' Or whatever your control's class is
called
For some reason, when I use NEW the usercontrols do not display. It is
very strange. I also tried using LoadTemplate to no avail. Please
help!

Jul 5 '06 #3

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

Similar topics

1
1776
by: .Net Newbie | last post by:
I am relatively new to .Net and have been coding an intranet site for my employer for a couple of months. I am currently stuck coding in a text-editor called EditPlus without access to the VS.Net IDE, and coding pages with the script directly in each page (not using the codebehind method) as most of my learning material has demonstrated. I started with the IBuySpy Portal (SDK version not VS Version) as my base portal and have coded...
3
1590
by: Damon | last post by:
I am working on a site in which I would like to have two dropdowns that will allow a user to navigate through the administrative pages of the site. The first would allow the user to choose the particular site that they would like to edit. The second would allow the user to select which admin screen they would like to edit. The second dropdown needs to be populated based on the selection in the first one. I want to encapsulate these...
1
1461
by: Michał Januszczyk | last post by:
I have the following code on my aspx page <%if(user_status==1){%><ctl:state1 runat="server" id="aaa"></ctl:state1><%}else if(user_status==2){%><ctl:state2 runat="server" id="bbb"></ctl:state2><%}else if(user_status==3){%><ctl:state3 runat="server" id="ccc"></ctl:state3><%}else if(user_status==4){%><ctl:state4 runat="server" id="ddd"></ctl:state4><%}% When I load the page, all four controls are inilialized (page_loa of each is fired ...
2
1431
by: ScottOnes | last post by:
Hi I have a placeholder that has multiple controls that need to be loaded and rendered to the user based on some user selections. I have to loop through the choices that the user makes and then load the controls. I am doing this in the protected override void Render(HtmlTextWriter writer) method. protected override void Render(HtmlTextWriter writer) { foreach (Selection in UsersSelection) {
3
2793
by: Nathan Sokalski | last post by:
When I view any page in my application a second time, I recieve the following error: System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize) +313 System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +201 System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState) +263
1
2964
by: SteveComplex | last post by:
I'm currently working on a project developing a web application that makes heavy use of 3rd-party controls, popup windows and frames ( not my design I hasten to add ). Some of the pages make use of several user controls embedded in a tab control. Needless to say that the page size can be somewhat on the large size, including a lot of information being stored in viewstate. I'm currently looking for a solution to resolve the problem of...
11
3152
by: Ranginald | last post by:
This question is about how to handle an .aspx page that references multiple methods and where to store these methods (e.g. one codefile or multiple codefiles). PREFACE ======== I have a simple category/product asp.net/C# web site I am coding in web dev express and laying out in dreamweaver MX. I find the layout tools in web express difficult to use and implementation of complex templates much easier in dwmx.
9
3191
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will load with different data (locations, departments, etc.).
1
4349
by: Dave A | last post by:
I have a problem that I have boiled down to a very simple example. I have a user control that displays a some data from a business object. On one screen I have a collection of these business objects and wish to display the user control multiple times. On this web page I simply bind the repeater to the data source and in the ItemDataBound event dynamically load the user control via "LoadControl()". The user control contains an auto post...
4
1858
by: Greg | last post by:
I have a complex page (with 8 complex user controls, and many other asp.net controls.) I have 2 very similiar pages to create, each page differing only from the others in one control. What is the best way to achieve this? I would guess that I have 3 alternatives. 1.) Visual and Logic inheritance. I know absolutely nothing about this in ASP.NET, and I haven't found anything that appears immediately simple ( i am in a rush to get this job...
0
9589
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
10212
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
10047
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...
0
8872
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...
1
7410
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3962
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
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.