locked
Insert empty row on top of the gridview and add values RRS feed

  • Question

  • User868807549 posted

    Hi,

    We have a gridview control which was bind by a datatable. This datatable retrieve data, based on the part availability from the stockist location by ascending order. The part number passing as a parameter during runtime. I want to get one of the particular stockist row details from the gridview and move that entire row on top of the row of the gridview. I got the row values and I can hide that particular stockist row.

    I want to insert an empty row and add the stockist row data on top of the row in the gridview control.

     

    Monday, February 18, 2013 9:24 AM

Answers

  • User1938476581 posted

    Hi,

    You can try adding an empty row like this

    TableCellCollection fields = e.Row.Cells; 
               TableCell headerCell = new TableCell(); 
    
               headerCell.ColumnSpan = fields.Count; 
               headerCell.Text = "Header";//You can also add controls 
               headerCell.HorizontalAlign = HorizontalAlign.Center; 
    
               GridViewRow rowHeader = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
                rowHeader.Cells.Add(headerCell); 
               rowHeader.Visible = true; 
              
              GridView1.Controls[0].Controls.AddAt(0,rowHeader); //Change index


     Please refer here

    http://forums.asp.net/t/1217361.aspx

    http://www.codeproject.com/Questions/81714/Add-New-Empty-row-to-gridview-control

    Hope it can help you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 19, 2013 2:09 AM

All replies

  • User1938476581 posted

    Hi,

    You can try adding an empty row like this

    TableCellCollection fields = e.Row.Cells; 
               TableCell headerCell = new TableCell(); 
    
               headerCell.ColumnSpan = fields.Count; 
               headerCell.Text = "Header";//You can also add controls 
               headerCell.HorizontalAlign = HorizontalAlign.Center; 
    
               GridViewRow rowHeader = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
                rowHeader.Cells.Add(headerCell); 
               rowHeader.Visible = true; 
              
              GridView1.Controls[0].Controls.AddAt(0,rowHeader); //Change index


     Please refer here

    http://forums.asp.net/t/1217361.aspx

    http://www.codeproject.com/Questions/81714/Add-New-Empty-row-to-gridview-control

    Hope it can help you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 19, 2013 2:09 AM
  • User-134477160 posted

    Insert empty row on top of the gridview and add values

    http://www.codeproject.com/Articles/16036/GridView-with-insert-line

    Use GridView's FooterRow.

    Tuesday, February 19, 2013 11:03 PM