Click here to Skip to main content
15,909,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello experts
I have create a new row in my datagridview in which i show totalamount .
My code is
C#
dt.Rows.Add();
               DgReport.AutoGenerateColumns = false;
               DgReport.DataSource = dt;

              int row = DgReport.Rows.Count - 1;
              DgReport["InvoiceNumber", row].Value = "Total";
              DgReport["OrignalAmount", row].Value = dt.Rows[0]["OrgAmount"].ToString();
              DgReport["DueAmt", row].Value = dt.Rows[cont - 1]["UnderPayment"].ToString();


but when i click on this row the data has removed ..how can fix it

Thanks
Posted
Updated 29-Aug-13 21:47pm
v2
Comments
blitzkrieged 1-Sep-13 5:35am    
try something like this:

int row = dataGridView1.Rows.Add(new DataGridViewRow());
DgReport.Rows[row].Cells["InvoiceNumber"].Value = "Total";
DgReport.Rows[row].Cells["OrignalAmount"].Value = dt.Rows[0].Cells["OrgAmount"].Value.ToString();
DgReport.Rows[row].Cells["DueAmt"].Value = dt.Rows[DgReport.RowCount - 1].Cell["UnderPayment"].Value.ToString();

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