PDA

Click to See Complete Forum and Search --> : DataGrid


billrogers
Jun 3rd, 2002, 04:16 PM
I have a problem with my datagrid, in my page load I have the following:


Sub Page_Load(Sender As Object, E As EventArgs)

MyConnection = New OLEDBConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("/bowl/scores.mdb") & ";")

If Not(IsPostBack)
BindGrid()
End If

End Sub


But with the If Not(IsPostBack) there, when I click the edit for a row link, the page reloads and my grid is gone, If I take out the if not, the datagrid shows up, problem solved right? No. With the If Not gone, when I have finished updating the row and hit update, it wont do anything.... What the heck!!

Anyone seen anything like this?? Here is my aspx.

Thanks for any help
The frustrated Bill

Patoooey
Jun 4th, 2002, 02:35 PM
You have a BindGrid() in each of your datagrid events right ??


If Not(IsPostBack)
BindGrid()
End If

is ony for the first default view. After that you still need to bind the data to the grid but it's done in each event after you've edited,deleted, etc.


private void MyGrid_Edit(Object sender, DataGridCommandEventArgs e)
{
MyGrid.EditItemIndex = e.Item.ItemIndex;
String strEditKey = MyGrid.DataKeys[e.Item.ItemIndex].ToString();

// edit code goes here.

// bind grid for new view
BindGrid();

}



HTH
John

billrogers
Jun 4th, 2002, 03:38 PM
yes, I have the calls to BindGrid in each event, cancel, update, edit.