Hi
I am getting error - Object reference not set to an instance of the object.
objShippingOrdr.consignee.name = txtConsigneeName.Text;
Below is the code
public class ModelClass
{
public string OrderNo { get; set; }
public int shipping_charges { get; set; }
public int discount { get; set; }
public int cod_charges { get; set; }
public string PaymentType { get; set; }
public decimal OrderAmount { get; set; }
public Consignee consignee { get; set; }
}
public class Consignee
{
public string name { get; set; }
public string address { get; set; }
public string address_2 { get; set; }
public string city { get; set; }
public string state { get; set; }
public Int32 pincode { get; set; }
public Int32 phone { get; set; }
}
public void CreateShippingOrder()
{
var objShippingOrdr = new ModelClass();
objShippingOrdr.OrderNo = txtOrderNo.Text;
objShippingOrdr.PaymentType = ddlPaymentType.SelectedItem.Value;
objShippingOrdr.OrderAmount = Convert.ToDecimal(txtOrderAmount.Text);
objShippingOrdr.consignee.name = txtConsigneeName.Text;
objShippingOrdr.consignee.address = txtConsigneeAddress.Text;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
CreateShippingOrder();
}
Thanks