1
呃!無法理解這裏發生了什麼。sqldatasource.select在顯式選擇調用時沒有考慮FilterExpression?
當在SqlDataSource1上使用過濾器時,正確應用該過濾器以正確填充相應的gridview。
這就是說,過濾不適用於我用於獲取數據庫插入部分的DataView的手動選擇。
我在做什麼錯?有什麼事情我不知道?
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();
}
}