Results 1 to 3 of 3

Thread: DataGrid

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367

    DataGrid

    I have a problem with my datagrid, in my page load I have the following:

    Code:
        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
    Attached Files Attached Files
    Last edited by billrogers; Jun 3rd, 2002 at 04:20 PM.

  2. #2
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    You have a BindGrid() in each of your datagrid events right ??

    Code:
    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.

    Code:
    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    yes, I have the calls to BindGrid in each event, cancel, update, edit.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width