Create DataTable:
private void temptable()
{
DataTable dt = new DataTable();
dt.Columns.Add("ItemDetail_ID", typeof(int));
dt.Columns.Add("Item_Price", typeof(string));
dt.Columns.Add("Item_Barcode", typeof(string));
dt.Columns.Add("Quantity", typeof(string));
dt.Columns.Add("image", typeof(string));
Session["dt"] = dt;
BindGrid();
}
Bind DataTable with GridView:
protected void BindGrid()
{
gvattributes.DataSource = Session["dt"] as DataTable;
gvattributes.DataBind();
}
Enter Data in DataTable:
protected void btnSave_Click(object sender, EventArgs e)
{
DataTable dt=Session["dt"] as DataTable;
dr = dt.NewRow();
dr["ItemDetail_ID"]= txtItemDetail_ID.Text.ToString();
dr["Item_Price"] = txtItem_Price.Text;
dr["Item_Barcode"] = txtItem_BarCode.Text;
dr["Quantity"] = txtQuantity.Text;
dr["image"] = txtItemDetail_ID.Text.ToString();
Session["dt"] = dt;
BindGrid();
}
No comments:
Post a Comment