I would like to know how to convert values into two decimals when I load them into DataGridView and TextBoxes from the sqlserver two tables.This is my code.I tried txtgrandTotal.Text = Total.ToString("#,0.00") code,when I insert data into database
public void loadDataToUpdate()
{
DynamicConnection con = new DynamicConnection();
try
{
con.sqlquery("SELECT p.PO_No,p.Supplier_ID,p.Date,p.RequiredDate,p.GrandTotal,b.BookName,c.ISBN_No,c.OrderQuantity,c.UnitPrice,c.Total FROM TBL_PO_Cart AS c INNER JOIN TBL_Book AS b ON c.ISBN_No = b.ISBN_No INNER JOIN TBL_PO AS p ON c.PO_No=p.PO_No where p.PO_No='" + cmbPO.Text + "'");
con.mysqlconnection();
con.datatable();
SqlDataAdapter da = new SqlDataAdapter(con.cmd);
DataSet ds = new DataSet();
da.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
txtPONo.Text = ds.Tables[0].Rows[i][0].ToString();
cmbsupID.Text = ds.Tables[0].Rows[i][1].ToString();
date1.Text = ds.Tables[0].Rows[i][2].ToString();
requireddate.Text = ds.Tables[0].Rows[i][3].ToString();
txtgrandTotal.Text = (ds.Tables[0].Rows[i][4].ToString());
}
con.dataread();
this.dataGridView1.Rows.Clear();
while (con.datareader.Read())
{
DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
row.Cells[0].Value = con.datareader["BookName"].ToString();
row.Cells[1].Value = con.datareader["ISBN_No"].ToString();
row.Cells[2].Value = con.datareader["OrderQuantity"].ToString();
row.Cells[3].Value = con.datareader["UnitPrice"].ToString();
row.Cells[4].Value = con.datareader["Total"].ToString();
dataGridView1.Rows.Add(row);
}
}
So I need to display txtgrandTotal textbox, datagridview column3 and column4 with 2 decimal places.Please help me