Refreshing Rows in DataGrid

Sad How to Clear or refresh the Rows in the DataGrid

I am having the data filled in my Datagrid and whenever I tried to fill some other data into that Datagrid, the older rows are not getting clear. How to Clear them Can anyone help me
I have tried the Code below and still unsuccessfull


DataGrid1.DataSource = nothing;
DataGrid1.DataBind();

 


Answer this question

Refreshing Rows in DataGrid

  • blacitect

    Is it possible for you to tell us more detail about what you are trying to do
    and how did u trigger to update the data grid (e.g. by button click).
    It seems to me that you are trying to update the data grid without post back to the server. (which of course data grid won't be refreshed unless u are using AJAX)

    Hope it helps,
    Ivan Wong


  • smak

    Have you remove the selected rows from the DataSet1
    Could you please post the code that you use to remove the selected rows
    it seems to me that the DataGrid has been refreshed, with the same data, that's why "seems" like not refreshing at all.

    Hope it helps,
    Ivan Wong


  • Osama Alborbar

    maybe,after you invoke the clear(),you should invoke AcceptChanges()


    DataSet.Clear()
    DataSet.AcceptChanges()

     






  • lanfong

    It seems to me that you haven't update the database after you remove the selected rows in the dataset. Have you called the Update method (SqlDataAdapter1.Update()) after remove the selected row from the dataset

    Hope it helps,
    Ivan Wong

  • mikemhc

    See I am filling the Datagrid using a dataset dynamically The DataSet is having Some 10 Rows.

    DataGrid1.DataSource = DataSet1;
    DataGrid1.DataBind();

    After Posting to the Server, Suppose the User Selects two Rows and and Checks the Checkbox over there and Clicks on a Button . Then I will delete the two rows from the database and again fills the remaining 8 rows to Datagrid from the Database. Before filling the Datagrid ,I ll refresh the DataGrid.DataSource property with Nothing and binds it.
    i.e as below
          DataGrid1.DataSource = Nothing;
          DataGrid1.DataBind();
    and Fills up the Data to DataGrid
          DataGrid1.DataSource = DataSet1;
          DataGrid1.DataBind();

    Tongue Tied Now the DataGrid is not refreshed at all .It still shows the old rows with out refreshing.

  • JIMMY-D-

    can you type the code over here

    Regards
    Heemanshu



  • Jonathan Green

    Hi,

    Instead of setting the datasource=nothing you call the clear method .od dataset and refill the dataset and bind it.

          DataSet1.Clear();
          SQLDataAdapeter1.Fill(DataSet1);
          DataGrid1.DataSource = DataSet1;
          DataGrid1.DataBind();

       
          DataSet.Clear remove all the previous data from the dataset

    Regards
    Heemanshu



  • RMS rookie

    Smile Thanks Heemanshu, Ivan & Bineon for the Help.
    The problem got cleared with that
    DataSet1.Clear();
    DataSet1.AcceptChanges();


    Thanks & Regards

    Venny

  • Refreshing Rows in DataGrid