Apply Filter on Child Data Grid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dorandoran
    New Member
    • Feb 2007
    • 145

    Apply Filter on Child Data Grid

    I have a applyfilter that works with another page (using this sample http://www.c-sharpcorner.com/Blogs/B...spx?BlogId=825). can similar be implemented with following datasource (following datasource is for child gridview). I have a label where user will input a value for filter. i like to take that value and implement it with the code i posted so that the childgrid now have filtered data. hope it makes sense. (see example here: http://www.codeproject.com/KB/aspnet...dGridView.aspx ) please suggest.

    Code:
    private DataTable ChildDataSource(string strlpID, string strSort)
    {
    SqlConnection conn;
    SqlDataAdapter daProducts;
    DataTable dsProducts;
    string strQRY = "";
    conn = new SqlConnection(@"Server=riverstone; Integrated Security=SSPI; Database=nw");
    strQRY = "SELECT [Orders].[CustomerID],[Orders].[OrderID]," +
     "[Orders].[ShipAddress],[Orders].[Freight],[Orders].[ShipName] FROM [Orders]" +
     " WHERE [Orders].[CustomerID] = '" + strlpID + "'" +
     "UNION ALL " +
     "SELECT '" + strlpID + "','','','','' FROM [Orders] WHERE [Orders].[CustomerID] = '" + strlpID + "'" +
     "HAVING COUNT(*)=0 " + strSort;
    daProducts = new SqlDataAdapter(strQRY, conn);
    dsProducts = new DataTable();
    daProducts.Fill(dsProducts);
    return dsProducts;
    }
    Last edited by Frinavale; Jun 17 '09, 02:13 PM. Reason: Added code tags. Please post code in [CODE] [/CODE] tags.
  • dorandoran
    New Member
    • Feb 2007
    • 145

    #2
    I added parameters and it's seems to be working. however, it breaks when I dont pick anything from the dropdown filter box. my drop down has 30,60 and 90 and "" which is filtered against quantity. so i get "input string was not a correct format" error when i dont select anything from the drop down. I want the parameter to be optional. for example, show all the records when nothing is picked from the dropdown. (filter part is working).

    Comment

    Working...