Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello, I`m making a program using Windows forms and I already built some codes, like this

1. Write a site url in Text Box then click Start Button, matched data showed in DataGridViews.

2. I have a 6 DataGridViews. In First DataGridView, matched data showed(step 1)
and then, other 5 DataGridviews will showed like cascade refer First DataGridView`s row`s
value(webApplicationName)

code is below

And Now I want to add this
1. Add Combobox and Add some conditions, for example, [Show all] and [See Over 100GB DB]

2. If I choose [See Over 100GB DB] option, in that DataGridView showed only matched rows.

3. It means, I want to filter Datagridview using Combobox Selection and Datasource is already

binded, so I want to do not change DataSource....

I try to find combobox and DataGridView, but usually related on Combobox in DataGridView....

And how can I get get first DataGridViews`s value(webApplicationName)

Please somebody help me.. I don`t have any idea...

Thanks

What I have tried:

C#
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;
            }

        }
Posted
Updated 11-Oct-16 22:19pm
v3

1 solution

I found the way. Using DataView

code is like this

C#
private void mtcbContentDBSearchCondition_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataView dvContentDatabase = new DataView(dtContent);

            if (mtcbContentDBSearchCondition.SelectedItem.ToString() == "All")
            {
                mgrdContentDatabase.DataSource = dtContent;
            }
            else
            {
                dvContentDatabase.RowFilter = string.Format("ContentDBSize >= 500000000", mtcbContentDBSearchCondition.SelectedItem.ToString());
                mgrdContentDatabase.DataSource = dvContentDatabase;
            }
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900