Hello there,
First:
Wrap your Page_Load code in
if(!page.IsPostBack)
{}
Second, you need to keep your DataTable in a Session or ViewState object as in the current scenario every button click will create a new
DataTable dt object.
So go like this after this:
DataTable dtprod= objdata.viewdata("Select * from product_master where sno='"+id+"'");
line
DataTable dtObj = null;
if (Session["YourSessionKey"] != null)
{
dtObj= (DataTable) Session["YourSessionKey"];
}
else
{
dtObj = new DataTable();
}
and use
dtObj in the click event instead of
dt and after this line :
dt.Rows.Add(dtrow);
add these statements
dtObj.AcceptChanges();
Session["YourSessionKey"] = dtObj;
Finally, remove this line DataTable dt = new DataTable(); and give your own name to Session key
YourSessionKey.
Hope it helps.
Good luck
Azee...