473,466 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

I'm missing something

39 New Member
Hello,

I have an aspx webpage.
On this page is a custom control.
In this control is a formview.
Inside this formview (edit page) is a 2nd custom control.
Inside the 2nd custom control is a repeater.
Inside the repeater is a checkbox list.
And of course inside the checkbox list are checkboxes which have the values i want to save.

The problem is occurring when I postback from my formview. eg. click update, a button posts back
My repeater control loses all of its items before I get a chance to see their values.

I tried enabling viewstate on the repeater but that didn't help.

I'm thinking I'm missing something simple.

My repeater is being databound in the asmx. Perhaps I'll try doing it in the codebehind.


Anyone have any ideas?
Apr 3 '09 #1
7 1966
BiffMaGriff
39 New Member
Ok the fix for this was weird.
I tried databinding my repeater when my custom control loads.
In my test page where I only have my 2nd custom control and and submit button, when I press the submit button the values in my checkboxes clear.
However! When I have my 2nd control inside my formview and I do the databind it actually retains its value!?!

Weird...
Apr 6 '09 #2
Frinavale
9,735 Recognized Expert Moderator Expert
You probably shouldn't be doing a DataBind in the Page Load.
Consider moving this to the Page PreRender event instead.
Apr 6 '09 #3
BiffMaGriff
39 New Member
Hmm, it doesn't seem to want to work when I put it in there. I lose all my values again.
Apr 6 '09 #4
Frinavale
9,735 Recognized Expert Moderator Expert
When do you dynamically get the content for the repeater?
In the Page Init Event?
Apr 6 '09 #5
BiffMaGriff
39 New Member
I load the values in the prerender for the repeater.
Apr 6 '09 #6
Frinavale
9,735 Recognized Expert Moderator Expert
You need to consider the page life cycle when developing ASP.NET applications, especially when you are loading dynamic content.

Say you using a control dynamically created (like your repeater) ...you dynamically load it with data and then it's sent to the browser.

When the user causes the page to post back all of the state information about the control is loaded. ASP.NET is able to tell if something has changed in the control by loading it's view state.

If your dynamically created control is missing key components (like rows, columns, checkbox lists, etc) at this point then the control's state cannot be loaded.

You have to dynamically instantiate and load the control in the Page Init event of the page's life cycle. After the Page Init event the control's state information is loaded....which means that the dynamically create controls are loaded with the user's selection and other event/state information.

Once this is done you will be able to get the user's selection.

Also, you have to keep in mind when you do your DataBind. If you do your DataBind in the Page Load event then any user entered information will also be lost.

With this in mind I suggest that you create and set the data source for your repeater in the Page Init event and I recommend that you do your DataBind event in the Page PreRender event.


For more information please see how to use dynamic controls in ASP.NET

-Frinny
Apr 7 '09 #7
BiffMaGriff
39 New Member
Awesome Frinny! My 2nd subcontol works perfectly now. Thanks for your help :)
Apr 7 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Stephanie Stowe | last post by:
You have a page. On top of the page, there are some search criteria and other input elements and a submit button. The submit button is clicked, sending a request to the server. Server-side code is...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
17
by: Justin Emlay | last post by:
I'm hopping someone can help me out on a payroll project I need to implement. To start we are dealing with payroll periods. So we are dealing with an exact 10 days (Monday - Friday, 2 weeks). ...
6
by: Just Me | last post by:
My Task List contains the following: At least one reference is missing the 'Name' attribute. Any suggestion on how toe find which project is missing it? Solution contains 25 projects. ...
8
by: Elijah Cardon | last post by:
1 1 1 1 1 1 2 2 2 1 1 1 3 3 3 1 1 1 4 4 1 2 1 1 5 5 2 2 1 1 6 6 3 2 1 1 7...
2
by: ken | last post by:
We have a user that has reported the following error when starting up our client application that uses a web service on our back end: System.Configuration.ConfigurationException: Missing required...
1
by: chadw | last post by:
Not sure what I am missing sure its probably something very simple, I need something to get my entered text out of the textbox and entered into a database currently the code looks like this. ...
0
by: amiben | last post by:
Hi everyone. I have this problem that I am experiencing when I move a certain site from one hosting to another hosting location. This is why I think this problem is not related to ASP code, rather...
12
by: The Frog | last post by:
Hi all, Does anyone have a way to print forms at design time directly from the IDE? I am not a great fan of the print screen to paint to print method. I would really like to know if anyone has a...
7
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It...
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
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,...
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...
1
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...
0
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...
0
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,...
0
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...
0
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...

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.