Row Filtering in dataset

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DBC User

    Row Filtering in dataset

    I have a data set which has a data table. This dataset is set as a
    datasource for a display grid. Before I assign the data set to data
    grid, I would like to elliminate some rows from the data table. How can
    I do this?

    I saw an example where I can identify the table and then apply the
    select on the table. Which returns the data rows. Is there a way I can
    remove the rows without doing this 2 step process of obtaining the data
    row and then put the data row back in the table etc.,??

    Thanks.

  • Chris Fulstow

    #2
    Re: Row Filtering in dataset

    Maybe try setting the SqlDataSource.F ilterExpression property?


    DBC User wrote:
    I have a data set which has a data table. This dataset is set as a
    datasource for a display grid. Before I assign the data set to data
    grid, I would like to elliminate some rows from the data table. How can
    I do this?
    >
    I saw an example where I can identify the table and then apply the
    select on the table. Which returns the data rows. Is there a way I can
    remove the rows without doing this 2 step process of obtaining the data
    row and then put the data row back in the table etc.,??
    >
    Thanks.

    Comment

    • DBC User

      #3
      Re: Row Filtering in dataset

      The original input is XML that I convert to DataSource. Any
      suggestions?
      Thanks.


      Chris Fulstow wrote:
      Maybe try setting the SqlDataSource.F ilterExpression property?

      >
      DBC User wrote:
      >
      I have a data set which has a data table. This dataset is set as a
      datasource for a display grid. Before I assign the data set to data
      grid, I would like to elliminate some rows from the data table. How can
      I do this?

      I saw an example where I can identify the table and then apply the
      select on the table. Which returns the data rows. Is there a way I can
      remove the rows without doing this 2 step process of obtaining the data
      row and then put the data row back in the table etc.,??

      Thanks.

      Comment

      • Chris Fulstow

        #4
        Re: Row Filtering in dataset

        Ahhh, ok...
        Maybe try setting the XmlDataSource.X Path property?
        Specifies an XPath expression to be applied to the XML data contained by the Data property or by the XML file indicated by the DataFile property.


        DBC User wrote:
        The original input is XML that I convert to DataSource. Any
        suggestions?
        Thanks.
        >
        >
        Chris Fulstow wrote:
        Maybe try setting the SqlDataSource.F ilterExpression property?


        DBC User wrote:
        I have a data set which has a data table. This dataset is set as a
        datasource for a display grid. Before I assign the data set to data
        grid, I would like to elliminate some rows from the data table. How can
        I do this?
        >
        I saw an example where I can identify the table and then apply the
        select on the table. Which returns the data rows. Is there a way I can
        remove the rows without doing this 2 step process of obtaining the data
        row and then put the data row back in the table etc.,??
        >
        Thanks.

        Comment

        • Dave Sexton

          #5
          Re: Row Filtering in dataset

          Hi,

          You can bind the grid to a DataView:

          DataView view = new DataView(myData Table);

          // the following code does not modify the underlying DataTable
          // it only provides a logical "view" of the data to which you can bind the grid
          view.RowFilter = "Column1 = 'a value.'";

          // Although we're assigning the DataView as the source and not the DataTable,
          // you can still configure the grid in exactly the same way as you would for your DataTable.
          // i.e. You can use the same column names for binding.
          // (Internally, most framework controls switch to a DataView anyway when binding to a DataTable, AFAIK.)
          grid.DataSource = view;

          The following link describes the expression syntax that you can use for the RowFilter property and other DataSet expressions:

          DataColumn.Expr ession property on MSDN:
          Gets or sets the expression used to filter rows, calculate the values in a column, or create an aggregate column.


          --
          Dave Sexton

          "DBC User" <dbcuser@gmail. comwrote in message news:1159901520 .542904.141000@ k70g2000cwa.goo glegroups.com.. .
          >I have a data set which has a data table. This dataset is set as a
          datasource for a display grid. Before I assign the data set to data
          grid, I would like to elliminate some rows from the data table. How can
          I do this?
          >
          I saw an example where I can identify the table and then apply the
          select on the table. Which returns the data rows. Is there a way I can
          remove the rows without doing this 2 step process of obtaining the data
          row and then put the data row back in the table etc.,??
          >
          Thanks.
          >

          Comment

          • Cor Ligthert [MVP]

            #6
            Re: Row Filtering in dataset

            DBC,

            There is nothing wrong with looping through the table and to remove the
            datarows you do not want
            If it is not a database related table, than it is not important if you use
            delete or remove.

            Cor

            "DBC User" <dbcuser@gmail. comschreef in bericht
            news:1159901520 .542904.141000@ k70g2000cwa.goo glegroups.com.. .
            >I have a data set which has a data table. This dataset is set as a
            datasource for a display grid. Before I assign the data set to data
            grid, I would like to elliminate some rows from the data table. How can
            I do this?
            >
            I saw an example where I can identify the table and then apply the
            select on the table. Which returns the data rows. Is there a way I can
            remove the rows without doing this 2 step process of obtaining the data
            row and then put the data row back in the table etc.,??
            >
            Thanks.
            >

            Comment

            Working...