DataTable dt = new DataTable(); dt = _bindDetails.GetCustomerDetails(customerId); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { txtCustomerName.Text = dr["CustomerName"].ToString(); txtTotalValue.Text = dr["TotalValue"].ToString(); txtAgreementValue.Text = dr["AgreementValue"].ToString(); txtBalanceAmount.Text = (decimal.Parse(txtTotalValue.Text.ToString()) - decimal.Parse(txtAgreementValue.Text.ToString())).ToString(); } }
you have use fore each loop but i think u have text box only once...try for loop and give proper index to datatable like txtCustomerName.Text=dt.Rows[0]["CustomerName"].ToString(); if it helps select as answer
txtCustomerName.Text = dr[1].ToString(); txtTotalValue.Text = dr[2].ToString();
txtCustomerName.Text=dt.Rows[0]["CustomerName"].ToString();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)