I've created
DataTable dt = new DataTable();
dt.Columns.Add("Type");
dt.Columns.Add("Address1");
dt.Columns.Add("Address2");
dt.Columns.Add("PostalCode");
dt.Columns.Add("Country");
DataRow drow = dt.NewRow();
drow["Type"] = ddlAddressType.SelectedItem.ToString();
drow["Address1"] = txtAddress1.Text;
drow["Address2"] = txtAddress2.Text;
drow["PostalCode"] = txtPostalCode.Text;
drow["Country"] = ddlCountry.SelectedItem.ToString();
dt.Rows.Add(drow);
Session["Address"] = dt;
tried to add the value into a gridview using the following code:
public void populateAddressGridView()
{
if (Session["Address"] != null)
{
DataTable dt = (DataTable)Session["Address"];
if ((dt != null) && (dt.Rows.Count > 0))
{
AddressGridView.Visible = true;
AddressGridView.DataSource = dt;
AddressGridView.DataBind();
}
else
{
AddressGridView.Visible = false;
}
}
but the fields are empty without any value after adding a new data row. if i enable autogeneration of fields, i am able to view the generated data.
how do i go about solving this problem?