Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. DataGridView filter

DataGridView filter

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpdatabasesql-servervisual-studiosysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kensai
    wrote on last edited by
    #1

    I have a DataGridView bound to a table in Sql Server CE. I'd like to filter results but I couldn't figure it out so far. I'm trying to use DataView RowFilter but I couldn't manage it to work. Could you please tell me what should I look for? Here's the code, auto-generated by VS.NET, to bind data:

    this.gridRecords.DataSource = this.RecordsBindingSource;
    this.RecordsBindingSource.DataMember = "Records"; //table name is Records
    this.RecordsBindingSource.DataSource = this.tempRecordsDataSetBindingSource;
    this.tempRecordsDataSetBindingSource.DataSource = this.tempRecordsDataSet;
    this.tempRecordsDataSetBindingSource.Position = 0;
    this.tempRecordsDataSet.DataSetName = "TempRecordsDataSet";
    this.tempRecordsDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
    this.RecordsTableAdapter.ClearBeforeFill = true;
    this.RecordsTableAdapter.Fill(this.tempRecordsDataSet.Records);

    This is what I tried:

    this.tempRecordsDataSet.Records.DefaultView.RowFilter = "Field = 1234567891";

    W 1 Reply Last reply
    0
    • K kensai

      I have a DataGridView bound to a table in Sql Server CE. I'd like to filter results but I couldn't figure it out so far. I'm trying to use DataView RowFilter but I couldn't manage it to work. Could you please tell me what should I look for? Here's the code, auto-generated by VS.NET, to bind data:

      this.gridRecords.DataSource = this.RecordsBindingSource;
      this.RecordsBindingSource.DataMember = "Records"; //table name is Records
      this.RecordsBindingSource.DataSource = this.tempRecordsDataSetBindingSource;
      this.tempRecordsDataSetBindingSource.DataSource = this.tempRecordsDataSet;
      this.tempRecordsDataSetBindingSource.Position = 0;
      this.tempRecordsDataSet.DataSetName = "TempRecordsDataSet";
      this.tempRecordsDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
      this.RecordsTableAdapter.ClearBeforeFill = true;
      this.RecordsTableAdapter.Fill(this.tempRecordsDataSet.Records);

      This is what I tried:

      this.tempRecordsDataSet.Records.DefaultView.RowFilter = "Field = 1234567891";

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Your idea of using DataView is correct. However when using view, don't bind the control to the original data table, bind it to the view.

      The need to optimize rises from a bad design. My articles[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups