Problem displaying data in gridview with object data source (L2S)
I have a gridview using object datasource for data binding. Everything开发者_Go百科 is working fine except, When i add some new records to data it is not displaying immediately, it requires a refresh. I am using L2S Business Object with Object Data Source. Same thing in update and delete events.
I think you miss EditIndex property, change it on every event, like :
protected void HlnkbInsert_Click(object sender, EventArgs e)
{
...
gv.EditIndex = -1;
DataBindGV();
}
protected void gv_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
...
gv.EditIndex = -1;
DataBindGV();
}
protected void gv_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
...
gv.EditIndex = -1;
DataBindGV();
}
protected void gv_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
...
gv.EditIndex = e.NewSelectedIndex;
DataBindGV();
}
Are you re-binding your GridView after making the changes to your data?
精彩评论