473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Web UserControl - Database

Hi!

I'm a little confused now over the following scenario.

I have a webpage with a few buttons and fields and several UserControls
dynamically created from database. All the controls are crated using
the same "template" but are containing different text and so on
depending on the database. All controls contain two buttons.

My first intuition was to create the user controls as early as
possible, in Page_Load or earlier. This worked fine until I implemented
the functions of my buttons (both on the parent page and user
controls). The buttons manipulate the content of the database and those
changes should be reflected by the user controls but they don't.
Nothing strange about that I think because the code of the button
events execute after Page_Load. Now I created a method that creates the
dynamic controls. I cal the method from the Page_Load and from the
event handlers, but that's not working good because then I get two
sets of controls when I click a button. Perhaps nothing strange about
that but the strange thing is, and what I don't understand, is that
when I cal the method from the user controls event handler, no controls
are created. The method is called, I verified that, but It don't create
any controls. Perhaps it had something to do with that control can't
cal method to create it self. OK now I tried to clear the panel / place
holder I put the controls on, to get rid of the double controls. In the
browser it looks ok and I only see one set of controls. But something
is wrong because I have to click twice on the buttons on the control to
make them react correctly. It seams to be the "doPostBack" that, by
some reason, isn't correct. When the page load and e.g. 4 user controls
are created all with buttons "edit" and "delete" the "doPostBack" for
the first control has '_ctl1$...' the next has '_ctl2$...' etc (notice
the numbers 1, 2.. etc). When I click the edit button on the first
control the second control reacts. by displaying the "edit" box. But
now, when I look at the "doPostBack" for the buttons the first control
has '_ctl0$...' the second has '_ctl1$...' etc (the numbers start from
0) and now the buttons work for correct control. Apparently clearing
the panel to create new controls on it isn't working. I see the
correct controls but an "old" control is still there somewhere and
the new control gets wrong event handler associated.

But... now the big question is. What is the correct way of doing this.
Create user controls based on database and with buttons that can modify
the database??????

Thanks!!!
Björn

Jan 17 '06 #1
0 835

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

Similar topics

2
by: Jose Michael Meo R. Barrido | last post by:
I made a custom runded rectangle usercontrol. I used a function i found on the internet. the function works fine(see "GetRoundRect" below). I use the fullowing code to make my usercontrol...
2
by: Ben de Vette | last post by:
Hi, I like to load a UserControl onto a placeholder with some more control then just doing protected System.Web.UI.WebControls.PlaceHolder placeHolder; UserControl ascx =...
8
by: Raed Sawalha | last post by:
Hi, I have a strange problem with a usercontrol on a page. The usercontrol dispalyes three categories (From a database) when the user clicks a category they see all the products in a shop for...
1
by: Sammy | last post by:
When a user control access SQL Server, what happens if I host it multiple times on one webpage (create several instances of that user control), in terms of trips being made to the server? How can I...
1
by: freshRecruit | last post by:
Hi, I am having a problem, and is driving me nuts and my deadline is fast approaching. Please do help me.. This is a webapplication with a usercontrol which has some buttons for adding,...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
2
by: Simon Verona | last post by:
I have a usercontrol with code in the "leave" event which updates the final data back into a database. This works fine except if I have a default "accept" button on a form and invoke it by...
9
by: davidr | last post by:
Hi, I've researched this a lot and have a well understanding but still can't get the darn textbox in the javascript. I have a textbox that is set to runat="server" and I have a client...
4
by: Martin | last post by:
Hi everyone ! For those who haven't read my previous post, I have a problem with a UserControl. When I try to display it on a form, controls seem to appear one after one. In the following...
1
by: jf4m | last post by:
I have a repeater (which has only an usercontrol in its itemtemplate) that will allow the user to add rows to itself. To do this without losing any already existing data, i am saving values from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...

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.