Quote:
Originally Posted by Imar
Does it really bind? Or reconstruct the data from View State?
Do you actually see the deleted item disappear from the list? That's typically the reason to manually call DataBind: to force a refresh of the data.
Imar
|
Yes Iâm sure. Hereâs how Iâve figured out that gvwCategories.DataBind statement (inside gvwCategories_RowDeleted event handler) isn't really necessary:
1 â first I've delete
gvwCategories.DataBind(); statement ( inside
gvwCategories_RowDeleted event handler )
Code:
protected void gvwCategories_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
gvwCategories.SelectedIndex = -1;
// gvwCategories.DataBind();
dvwCategory.ChangeMode(DetailsViewMode.Insert);
}
2 â I then browsed to
ManageCategories.aspx page, which displayed all the available categories
3 â I then opened Sql server and manually added a new entry to
tbh_Categories table ( in other words, Iâve created a new category and named it
Y ). Now if Asp.Net does perform automatic data binding when some category is deleted, then
gvwCategories will also display new category
Y
4 â Iâve then deleted
âBeer-related articlesâ category ( by pressing Delete button)
5 â after a postback,
gvwCategories also displayed category
Y
Thus, if Asp.Net didnât perform automatic binding, but instead reconstructed the data from viewstate, then
gvwCategories wouldnât also display category
Y.
BTW - I did similar checks for code on pages 255 and 256