Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,768 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I have a datatable like this:
//create datatable and add column
Amortable = new DataTable();
Amortable.Columns.Add("Terms", typeof(int));
Amortable.Columns.Add("Principal", typeof(double));
Amortable.Columns.Add("Interest", typeof(double));
Amortable.Columns.Add("Payment", typeof(double));
Amortable.Columns.Add("Balance", typeof(double));
//add row
for (int i = 0; i < Convert.ToInt32(off.Terms)*12; i++)
{
DataRow row = Amortable.NewRow();
row["Balance"] = Convert.ToDouble(off.LoanAmt);
row["Terms"] = i+1;
row["Payment"] = Convert.ToDouble(off.Payment);
row["Interest"] = Convert.ToDouble(off.APR) / 12 / 100 * Convert.ToDouble(row["Balance"]);
row["Principal"] = Convert.ToDouble(row["Payment"]) - Convert.ToDouble(row["Interest"]);
if (i > 0)
{
row["Balance"] = Convert.ToDouble(row["Balance"]) - Convert.ToDouble(row["Principal"]);
}
Amortable.Rows.Add(row);
after running above code, I couldn't see data in datagrid.
if someone pick my mistake in this code, I would be very appreciated.
thanks,
c00012
Try specifying the binding, for example:
<DataGridTextColumn Header="Term" Binding="{Binding Terms}" IsReadOnly="True"/>
But if you set AutoGenerateColumns="True" to your data grid, then the columns and rows will appear automatically.