我真的做节目,我已经建立了一些代码,这样如何使用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) –