Meh! Can't understand what happens here.
The filter is correctly applied when used on SqlDataSource1, to correctly populate the corresponding gridview.
That being said, the filtering isn't applied on the manual select that I use to get a DataView, for the database insertion part.
What am I doing wrong? Is there something going on that I'm not aware of?
SqlDataSource1.FilterExpression = (string)ViewState["filtre"];
cmdApply.Text = (string)ViewState["filtre"];
DataView thingie = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
thingie.RowFilter = (string)ViewState["filtre"];
DataView verifdv = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty);
verifdv.Sort = "filterClient";
SqlConnection dbconn = new SqlConnection(SqlDataSource1.ConnectionString);
foreach ( DataRow dr in thingie.Table.Rows ) {
if ( verifdv.Find(dr["orgID"]) == -1 ) {
SqlCommand addFilter = new SqlCommand("INSERT INTO dbo.usermetafilter (filterUser, filterClient) VALUES (@user, @client)", dbconn);
addFilter.Parameters.Add("@user", SqlDbType.NVarChar).Value = "dummyvalue";
addFilter.Parameters.Add("@client", SqlDbType.Int).Value = dr["orgID"];
addFilter.Connection.Open();
addFilter.ExecuteNonQuery();
addFilter.Connection.Close();
}
}