Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
please some one tell me how to add a new empty row at the top of the gridview and also it should be editable and also add the data at the top of gridview.

Thanks and regards,
amol
Posted
Updated 24-Mar-23 22:04pm

Have a look at this article:
Editable Nested DataGrid[^]

AmolNagrkar wrote:
add the data at the top of gridview

Adjust this according to your choice in the codebase above.
 
Share this answer
 
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //This is a Test Condition
        if (e.Row.RowIndex % 2==0)
        {
            GridViewRow g = new GridViewRow(-1,-1, DataControlRowType.DataRow, DataControlRowState.Normal);
            for (int i = 0; i < e.Row.Cells.Count; i++)
            {
                //creating table Cells
                TableCell tCell = new TableCell();
                tCell.Text = "&nbsp;";
                //Add Cells
                g.Cells.Add(tCell);
                //Set Color for Empty Cell
                g.BackColor = System.Drawing.Color.Red;
            }
            Table tbl = e.Row.Parent as Table;
            //add rows
            tbl.Rows.Add(g);
        }
    }
 
Share this answer
 
Comments
Muni1207 25-Feb-14 18:00pm    
Hi,

Good Today,

This above soultion is working fine for me, but custome is get added in the girdview on the below th actual row.
I need your help on it to make custome row on the top of the grid.
Thanks in Advance

Thanks,
Muni
Hi,

Good Today,

This above soultion is working fine for me, but custome is get added in the girdview on the below th actual row.
I need your help on it to make custome row on the top of the grid.
Thanks in Advance

Thanks,
Muni
 
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