简体   繁体   中英

ASP.NET ListView SelectMethod

I'm sorry for being ignorant about this and I can't find the answer anywhere - but I suspect it's because I do not know how to word the query.

Anyway, I have a ListView on an ASP.NET page, with a SelectMethod called "GetData".

On the page_load event, I'm retrieving a references to various labels using

this.Master.FindControl(....

This works fine, but as soon as this is called, I've noticed control suddenly jumps to my GetData method - the SelectMethod of the ListView.

This is causing me some issues since the local database is only populated AFTER I've retrieved references to various controls etc - ie the SelectMethod is called before I've had chance to fill the DB.

I'm fairly inexperienced (as you've guessed) with ASP, but could someone please explain why this happens. ie What exactly causes the SelectMethod to be called.

Thanks for enlightening me.

According to this MSDN , the Select Method appears to be called in the PreRender phase.

The page load happens before the PreRender.

Try putting your database populating code in the page init.

protected void Page_Init(object sender, EventArgs e) {

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM