On button click add element to grid view using List

Sep 24 2016 8:27 AM
List&lt;DOBillDetails&gt; listDOBillDetails = new List&lt;DOBillDetails&gt;();<br /><br /> protected void btnAdd_Click(object sender, EventArgs e)<br /> {<br /><br /> try<br /> {<br /> <br /><br /> DOBillDetails objDOBillDetail = new DOBillDetails();<br /> objDOBillDetail.ProductId = Convert.ToInt32(ddProductName.SelectedValue);<br /> objDOBillDetail.Description = Convert.ToString(txtDescription.Text);<br /> objDOBillDetail.Unit = Convert.ToInt32(txtUnit.Text);<br /> objDOBillDetail.Qty = Convert.ToInt32(txtQty.Text);<br /> objDOBillDetail.UnitPrice = Convert.ToInt32(txtUnitPrice.Text);<br /> objDOBillDetail.TaxPer = Convert.ToString(txtTaxPer.Text);<br /> objDOBillDetail.Discount = Convert.ToString(txtDiscount.Text);<br /> objDOBillDetail.Total = Convert.ToInt32(txtTotal.Text);<br /><br /> listDOBillDetails.Add(objDOBillDetail);<br /><br /> //dtgBill.DataSource = objBLLBillDetails.FillGrid(ddProductName.SelectedValue, txtDescription.Text, txtUnit.Text,<br /> //txtQty.Text,txtUnitPrice.Text, txtTaxPer.Text, txtDiscount.Text, txtTotal.Text);<br /> dtgBill.DataSource = listDOBillDetails;<br /> dtgBill.DataBind();<br /> }<br /> catch (Exception ex)<br /> {<br /> throw;<br /> }<br /> }

Answers (2)