.NET Event When Binding Was Finished
What do you call the event when binding was finished?
Example: 1. An SqlDataSource named SqlDataSource1 is present on the page. 2. A GridView named GridView1 is also pres开发者_如何学JAVAent; its DataSource is the SqlDataSource1.
Now, I want to run some codes right after populating GridView1.
Thanks in advance!
Depends on what you mean by "when I populate it." You can usually get what you need done on the RowDataBound event, but it depends on whether or not you are calling DataBind() explicitly or not. I'm thinking you probably want to call your code on the PreRender() event for your control, but you probably need to provide more examples of what you're actually being limited by.
Take a look at DataBindingComplete event. From MSDN:
This event is raised when the contents of the data source change or when the value of the DataSource, DataMember, or BindingContext property changes.
Are you calling DataBind on the grid yourself. If yes, you can make a simple method called BindDataGrid. In this method you call your SqlCommand to fill the data source, call DataBind on the grid then your code.
BindDataGrid() {
// Fill the data source
sqlDataSource1 = FillDataSource();
// Bind the GridView
grid.DataSource = sqlDataSource1;
grid.DataBind();
// Other code
}
Thanks to your reply! I've already found it. It's the DataBound event. What I meant in my question was, AFTER or when FINISHED binding GridView with SqlDataSource, what event will be raised. Anyway, your answers were really appreciated! Thanks again!
精彩评论