我真的做節目,我已經建立了一些代碼,這樣如何使用DataGridView的組合框不使用Windows窗體改變數據源
寫文本框中輸入網站網址,然後點擊開始按鈕來篩選,匹配數據顯示在DataGridViews中。
我有一個6 DataGridViews。在首先的DataGridView,匹配的數據顯示(步驟1) ,然後,其他5個DataGridviews將顯示像級聯指首先的DataGridView row`s值(webApplicationName)
代碼如下
private void mtbtnStart_Click(object sender, EventArgs e)
{
string webApplicationName = string.Empty;
string siteID = string.Empty;
mtlblError.Text = "No record returned.";
Migration_Status_DAC dac = new Migration_Status_DAC();
DataSet ds = new DataSet();
//Web Application
ds = dac.SelectWebApplicationStatus(mtextUrl.Text);
DataTable dt = ds.Tables[0];
if (ds != null && dt != null && dt.Rows.Count > 0)
{
webApplicationName = dt.Rows[0]["AppName"].ToString();
mgrdWebApplication.DataSource = dt;
//Content Database
ds = dac.SelectContentDatabaseStatus(webApplicationName);
DataTable dtContent = ds.Tables[0];
if (ds != null && dtContent != null && dtContent.Rows.Count > 0)
{
mtlblError.Visible = false;
mgrdContentDatabase.DataSource = dtContent;
//SiteCollection
ds = dac.SelectSiteCollectionStatus(webApplicationName);
DataTable dtSiteCol = ds.Tables[0];
if (ds != null && dtSiteCol != null && dtSiteCol.Rows.Count > 0)
{
mgrdSiteCollections.DataSource = dtSiteCol;
//Sites
ds = dac.SelectSitesStatus(webApplicationName);
DataTable dtSites = ds.Tables[0];
if (ds != null && dtSites != null && dtSites.Rows.Count > 0)
{
siteID = dtSites.Rows[0]["SiteID"].ToString();
mgrdSites.DataSource = dtSites;
//Lists
ds = dac.SelectListsStatus(siteID);
DataTable dtLists = ds.Tables[0];
if (ds != null && dtLists != null && dtLists.Rows.Count > 0)
{
mgrdLists.DataSource = dtLists;
}
//Document Library
ds = dac.SelectDocumentLibraryStatus(siteID);
DataTable dtDocLib = ds.Tables[0];
if (ds != null && dtDocLib != null && dtDocLib.Rows.Count > 0)
{
mgridDocumentLibrary.DataSource = dtDocLib;
}
}
else
{
mtlblError.Visible = true;
}
}
else
{
mtlblError.Visible = true;
}
}
else
{
mtlblError.Visible = true;
}
}
else
{
mgrdWebApplication.DataSource = null;
mgrdContentDatabase.DataSource = null;
mgrdSiteCollections.DataSource = null;
mgrdSites.DataSource = null;
mgrdLists.DataSource = null;
mgridDocumentLibrary.DataSource = null;
}
}
而現在,我想添加這個
添加組合框,並添加一些條件,例如,[查看全部]和[見超過100GB DB]
如果我選擇[查看超過100GB的數據庫]選項,則DataGridView只顯示匹配的行。
這意味着,我想用組合框選擇過濾的DataGridView和數據源已經
綁定,所以我想不改變數據源....
我試圖找到組合框和DataGridView的,但通常與對組合框在DataGridView中....
和我如何能得到獲得第一DataGridViews`s值(webApplicationName)
請有人幫助我。我不有任何想法...
感謝
可能重複o f [過濾DataGrid動態名稱與TextBox](http://stackoverflow.com/questions/34221657/filter-datagrid-for-name-with-textbox-dynamically) –