Solved

Page Event Handler Problems

Posted on 2010-11-13
3
369 Views
Last Modified: 2012-05-10
I have a page that contains a form.  On the form, there are about 6 drop-down boxes, each which load from six different tables in my database (using SqlDataSources).

On Page_Load, I am loading a record into a reader in the code-behind and then populating the fields of the form with data from the reader. The drop-down boxes are *supposed* to be populated with ID values from the record, but I am getting an "index out of range" error when doing this on Page_Load.

I thought maybe the problem was that the code was trying to populate the .SelectedValue of the drop-down lists before the lists even built on the page, thus throwing the out of range error. So I moved my reader code to Page_Render instead, to give the lists a chance to load, and got some other error about only one server side form tag being allowed on the page. This is weird, because there *is* only one server side form tag?

Anyhow, just to get the thing to load, I took the runat="server" out of the form tag and got my page to come up, but the form was empty! Ugh.

My question is:  How can I populate my data into the form after the drop down lists load so I don't get an indexing error? Is there another page event I should try? Page_Init is too early, I think.
0
Comment
Question by:vcbertini
  • 2
3 Comments
 

Author Comment

by:vcbertini
Comment Utility
I think I found the solution to this - doing my reader stuff on Page_LoadCompleted, however, it's not allowing me to have a <form runat="server"> Any insight as to why?
0
 
LVL 16

Accepted Solution

by:
BurnieP earned 500 total points
Comment Utility
At this moment, I don't know the answer about the <form runat="server"> issue.  

But I would try to bind your reader stuff in the Page_PreRenderComplete event instead.

Hope it helps.
0
 

Author Closing Comment

by:vcbertini
Comment Utility
Still not sure why I can't have the form runat="server" on the page.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now