Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Page Event Handler Problems

Posted on 2010-11-13
3
Medium Priority
?
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:vcbertini
ID: 34129760
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 1500 total points
ID: 34130994
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
ID: 34227508
Still not sure why I can't have the form runat="server" on the page.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 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