c# - Copy gridview rows in another gridview on a button_click -


i have textbox , search button fills first gridview. after second button copies first grid rows in second grid . after should able search again in first grid , attach other results second grid. error. thnx in advance. here code:

public partial class grid: system.web.ui.page 

{

datatable dt = new datatable(); private datatable dt1 {     set { viewstate.add("dt1", value); }     { return (datatable)viewstate["dt1"]; } }   private void fill_grid() {     string query = "select * table " +     " field1 '" + textbox1.text + "' or filed2 '" +textbox1.text + "'";             sqlconnection cnn = new sqlconnection(...);     sqlcommand cmm = new sqlcommand(query,cnn);     cmm.commandtype = system.data.commandtype.text;     sqldataadapter mydataadapter = new sqldataadapter(cmm);     dataset ds = new dataset();     cnn.open();     mydataadapter.fill(ds, "client");     dt1 = ds.tables["klient"];     dataview dv = new dataview(dt1);     gridview2.datasource = ds.tables["klient"].defaultview;     gridview2.databind();   } protected void button2_click(object sender, eventargs e) {     fill_grid(); } protected void button1_click(object sender, eventargs e) {     fill_second_grid(); }  private void fill_second_grid() {      datarow dr;      foreach (gridviewrow row in gridview2.rows)     {         dr = dt.newrow();             dr["email"] = row.cells[0].text; ;             dt.rows.add(dr);     }      gridview3.datasource = dt;     gridview3.databind(); }     

}


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -