Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

Page Event Handler Problems

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
vcbertini
Asked:
vcbertini
  • 2
1 Solution
 
vcbertiniAuthor Commented:
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
 
BurniePCommented:
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
 
vcbertiniAuthor Commented:
Still not sure why I can't have the form runat="server" on the page.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now