954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Add rows in datagridview

Hi Fiends,

How can i add new rows in datagridview on run time.

accualy I have a table, in which i have Many records But i want some specific records on datagridview .& for that I am using If condition , & whic records are correct accoding to that if condition only those records must be in datagridview .so i am gettin those records but not able to switching in datagridview Please give me sugation for it.

manoj_582033
Light Poster
39 posts since Nov 2008
Reputation Points: 10
Solved Threads: 2
 

you can create a new data table and ad according rows in it and after that you can bind a grid with this data source like this:

DataTable dt = new DataTable("good");
        foreach (DataRow dr in oldDt)
        {
            if (dr)//condition
            {
                dt.Rows.Add(dr);
            }
        }
        GridView1.DataSource = dt;
        Gridview1.DataBind();
vasioky
Newbie Poster
8 posts since Dec 2008
Reputation Points: 10
Solved Threads: 1
 

Thank You

This was very usefull code Thanks

manoj_582033
Light Poster
39 posts since Nov 2008
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You