So i have a main forum and a few child forums. For the main form, im using a search textbox with a dataview row filter. Although the problem is that in my child form im updating the database records, and then have to come back to the main form and have the DataGridView updated with the new records.

But when i try that, the datagridview isnt showing me an updated view even when i hard code DataView Filter.

  public void RefreshDGV()
    {
        //Method thats being called from child form
        SQL_Data.table.Clear();
        this.dataGridView1.RowCount = 1;
        this.dataGridView1.Rows.Clear();
        this.Refresh();
        this.dataGridView1.Refresh();
        this.DataGridFill();
        AptSearchRefill();

    }
   //Function that needs to set up a new view to show new/updated records
 public void AptSearchRefill()
    {
        try
        {
            DataView dvrefresh = new DataView(SQL_Data.table);
            dvrefresh.RowFilter = string.Format("apt_num LIKE '%{0}%'", apt_search.Text); 
           //Problem lies here^ Even when apt_search.text is hardcoded, still nothing.
            dataGridView1.DataSource = dvrefresh;
        }
        catch (Exception ex)
        {
            WriteToLog.Write(ClassName, ex.ToString(), StoreUser.Username.ToString());
        }
    }

Here are my suggestions, please review your code.

  1. LIKE operator cannot be used with numeric fields. In this case verify the exception log.
  2. May be you need to dispose/close the connection after updation and open before you read rows.
  3. Add break-points to examine the value of objects/variables in some locations in your code files.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.