c# - Save checked row of one dataGrid into another dataGrid -
c# - Save checked row of one dataGrid into another dataGrid -
i have simple datagrid stores info returned in json format in it. have added unbound checkbox column it. want store checked rows in datagrid. how should proceed.
my code
protected void btnsave_click(object sender, eventargs e) { foreach (datagriditem item in this.gv1.items) { checkbox chkbox = (checkbox)item.findcontrol("chkrows"); //if it's selected add together our new datagrid if (chkbox != null && chkbox.checked) { //save } } }
datasource 1st grid
searchapirequest.defaultapikey = "samplekey"; searchapirequest request = new searchapirequest(rawname: txtuser.text); seek { searchapiresponse response = request.send(); datatable dt = new datatable(); dt.columns.add("website"); dt.columns.add("first"); dt.columns.add("last"); dt.columns.add("jobs"); dt.columns.add("dobs"); dt.columns.add("educations"); dt.columns.add("addresses"); dt.columns.add("images"); dt.columns.add("url"); (int = 0; < response.records.count; i++) { datarow dr = dt.newrow(); dr["website"] = response.records[i].source.domain; dr["first"] = response.records[i].names[0].first; dr["last"] = response.records[i].names[0].last; dr["jobs"] = response.records[i].jobs.count > 0 ? response.records[i].jobs[0].display: ""; dr["dobs"] = response.records[i].dobs.count > 0 ? response.records[i].dobs[0].daterange.start.tostring() : ""; dr["images"] = response.records[i].images.count> 0 ? response.records[i].images[0].url:""; dr["educations"] = response.records[i].educations.count > 0 ? response.records[i].educations[0].display : ""; dr["addresses"] = response.records[i].addresses.count > 0 ? response.records[i].addresses[0].display: ""; dr["url"] = response.records[i].source.url; dt.rows.add(dr); } gv1.datasource = dt;// response.records[0].allfields.tolist(); gv1.databind();
c# asp.net datagrid
Comments
Post a Comment