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.

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();

Thank You

This was very usefull code Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.