Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Filter Datagridview using combobbox selection

$
0
0

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

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

        }

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.

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

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

Thanks



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>