Click here to Skip to main content
15,937,003 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i am retriving data from one page to another page'Gridview that time page not refresh...means value fatched but System can't add rows in DataGridview...then what can I do..?

for ex:
DataGridViewRow row = new DataGridViewRow();
row = dgvIndent.Rows[RowIndex];
row.Cells["varProductFullCode"].Value = ProductFullCode;

All method use for add but problem of Page cant refresh Second Time
i am also using this.Refresh(); but page is not Refreshed
Updated 5-Jul-10 2:10am
Christian Graus 5-Jul-10 6:49am    
It sounds like you're going between two pages, but I can't make sense of the question. Your code runs, then your page reloads, but the row is gone ?
Sandeep Mewara 5-Jul-10 8:10am    
Use PRE tags for code formatting next time onwards.

1 solution

decimal orderTotal = 0.0m;
decimal tax = 0.0m;
protected void gvOrderDetail_RowDataBound(object sender, GridViewRowEventArgs e)
//TODO: Calculate the orderTotal and the tax when RowType = DataRow
if (e.Row.RowType == DataControlRowType.Footer)
//Create the Row
GridViewRow row = new GridViewRow
(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
//Add the two Columns
//get a reference to the table that holds this row
Table tbl = (e.Row.Parent as Table);
//Add the row at the end of the list, but before the footer.
tbl.Rows.AddAt(gvOrderDetail.Rows.Count + 1, row);

//Don't forget to account for any changes in the footer. Since we added a row to show the tax,
//that tax must also be accounted for in our footer. Calculating the orderTotal and the tax
//is an exercise for the reader.
Label lbl;
lbl = (Label)e.Row.FindControl("lblTotal");
lbl.Text = String.Format("{0:C}", (orderTotal + tax));

private TableCell[] CreateCells()

TableCell[] cells = new TableCell[2];
TableCell cell;
Label lbl;

//The order item column
cell = new TableCell();
lbl = new Label();
lbl.Text = "Sales Tax";
cells[0] = cell;

//The price column
cell = new TableCell();
lbl = new Label();
lbl.Font.Bold = true;
lbl.Text = tax.ToString("C");
cell.HorizontalAlign = HorizontalAlign.Right;
cells[1] = cell;

return cells;
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