How to assign textbox value to gridview in asp textbox is a seperate object not a part of gridview. on button click event all text box values assign to grid view as neew row. i am wondering about how to do that i search a lot but can't find correct way to do that. ![enter image description here][1] DataTable dt = new DataTable(); DataRow dr = dt.NewRow(); if (e.CommandName.CompareTo("ADD") == 0) { dt.Columns.Add("id", System.Type.GetType("System.String")); dt.Columns.Add("Name", System.Type.GetType("System.String")); dt.Columns.Add("UnitPrice", System.Type.GetType("System.String")); dt.Columns.Add("Price", System.Type.GetType("System.String")); dt.Columns.Add("Quantity", System.Type.GetType("System.String")); dr["Id"] = GridView1.Rows[Convert.ToInt16(e.CommandArgument)].Cells[0].Text;//item id dr["Name"] = GridView1.Rows[Convert.ToInt16(e.CommandArgument)].Cells[1].Text;//item name dr["UnitPrice"] = GridView1.Rows[Convert.ToInt16(e.CommandArgument)].Cells[2].Text;//iten unit price dr["Price"] = "mkj"; dr["Quantity"] = "mkj"; dt.Rows.Add(dr); GridView2.DataSource = dt; GridView2.DataBind(); }

please see this img

Related posts

Recent Viewed