472,986 Members | 3,137 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,986 software developers and data experts.

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.StoredProcedure
.CommandText = "sp_s_Issues"
.Parameters.Add(New
SqlClient.SqlParameter("@ClientTaskID", CType(Page,
DMSPageBase).Task.ClientTaskID))
.Connection = sqlConn
End With

sqlAdapter.SelectCommand = sqlCmd
sqlAdapter.Fill(sqlSet)

x = 1

For Each row In sqlSet.Tables(0).Rows
ILD = LoadControl("issuelog_detail.ascx")

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

pnlIssues.Controls.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 2573
For Each row In sqlSet.Tables(0).Rows
ILD = LoadControl("issuelog_detail.ascx")

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

pnlIssues.Controls.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("issuelog_detail.ascx")

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

pnlIssues.Controls.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
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...
3
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...
1
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"...
2
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...
3
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...
1
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...
11
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...
9
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...
1
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...
4
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...
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=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
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...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
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 :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
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...
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...

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.