datatable - how to add row in temporary table data table in asp.net -



datatable - how to add row in temporary table data table in asp.net -

protected void add_new_click(object sender, system.eventargs e) { datatable dt= new datatable(); datarow dr; dr = dt.newrow(); string customerid = ((textbox)gridview1.footerrow.findcontrol("txtcustomerid")).text; string customername = ((textbox)gridview1.footerrow.findcontrol("txtcustomername")).text; string customerfathername = ((textbox)gridview1.footerrow.findcontrol("txtcustomerfathername")).text; dt.rows.add(dr); gridview1.datasource = dt; gridview1.databind(); viewstate["sajjad_viewstate"] = dt; }

try this:

protected void add_new_click(object sender, system.eventargs e) { datatable dt= new datatable(); // add together columns here dt.columns.add(new datacolumn("customerid")); dt.columns.add(new datacolumn("customername")); dt.columns.add(new datacolumn("customerfathername")); //create new row datarow dr= dt.newrow(); string customerid = ((textbox)gridview1.footerrow.findcontrol("txtcustomerid")).text; string customername = ((textbox)gridview1.footerrow.findcontrol("txtcustomername")).text; string customerfathername = ((textbox)gridview1.footerrow.findcontrol("txtcustomerfathername")).text; //populate columns info dr["customerid"] = customerid; dr["customerid"] = customername; dr["customerfathername"] = customerfathername; dt.rows.add(dr); gridview1.datasource = dt; gridview1.databind(); viewstate["sajjad_viewstate"] = dt; }

asp.net datatable viewstate

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -