dorandoran
Programmer
I have a applyfilter that works with another page(using this sample 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: ) please suggest.
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;
}
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;
}