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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. BindingSource Filter

BindingSource Filter

Scheduled Pinned Locked Moved C#
4 Posts 3 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.
  • S Offline
    S Offline
    shafiullah123
    wrote on last edited by
    #1

    I have to list boxes...and i have a datagrid with binded to complete table..and i am using DataGridCombocolumn with displaystyle as nothing to display the values from master tables in relation instead of their IDs... On selection change event of second list box i put this filter...values in both list boxes are selected...it shows correct values in debug mode........ MyBindingSource.Filter = "Column1="+cbCol1.SelectedValue+" AND Column2= "+cbCol2.SelectedValue; it gives following error Syntax error: Missing operand before 'And' operator.

    A J 2 Replies Last reply
    0
    • S shafiullah123

      I have to list boxes...and i have a datagrid with binded to complete table..and i am using DataGridCombocolumn with displaystyle as nothing to display the values from master tables in relation instead of their IDs... On selection change event of second list box i put this filter...values in both list boxes are selected...it shows correct values in debug mode........ MyBindingSource.Filter = "Column1="+cbCol1.SelectedValue+" AND Column2= "+cbCol2.SelectedValue; it gives following error Syntax error: Missing operand before 'And' operator.

      A Offline
      A Offline
      ABitSmart
      wrote on last edited by
      #2

      You might be missing the ' (quote). Try it this way, MyBindingSource.Filter = "Column1='"+cbCol1.SelectedValue+"' AND Column2= '"+cbCol2.SelectedValue+"'"; See the example here, Link[^]

      S 1 Reply Last reply
      0
      • A ABitSmart

        You might be missing the ' (quote). Try it this way, MyBindingSource.Filter = "Column1='"+cbCol1.SelectedValue+"' AND Column2= '"+cbCol2.SelectedValue+"'"; See the example here, Link[^]

        S Offline
        S Offline
        shafiullah123
        wrote on last edited by
        #3

        When i am doing it like that it gives error cannot convert System.Int32 to System.String Actually both are Primary key IDs in individual master tables....but the value coming here is string...If i am not using AND clause this is working fine with individual listbox filtering it is auto converting those strings...Its only then when i want to filter by values from both columns its creating prob...I am not facing any prob with combo box in the same situation.......Its the only list box thats irritating

        1 Reply Last reply
        0
        • S shafiullah123

          I have to list boxes...and i have a datagrid with binded to complete table..and i am using DataGridCombocolumn with displaystyle as nothing to display the values from master tables in relation instead of their IDs... On selection change event of second list box i put this filter...values in both list boxes are selected...it shows correct values in debug mode........ MyBindingSource.Filter = "Column1="+cbCol1.SelectedValue+" AND Column2= "+cbCol2.SelectedValue; it gives following error Syntax error: Missing operand before 'And' operator.

          J Offline
          J Offline
          jaypatel512
          wrote on last edited by
          #4

          (("Column1="+cbCol1.SelectedValue.ToString()+") AND (Column2= "+cbCol2.SelectedValue.ToString())); This might work... And one more thing. it might be && inspite of AND But not so sure. .

          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