asp.net - Get original object from DataRow in GridView C# -


i try display collection (ienumerable) of objects (generated via linq sql). therefore bind gridviews datasource property generated output of linq sql method. in selectedindexchanged event of gridview try convert selected rows dataitem original object end null value instead.

here code:

protected void page_load(object sender, eventargs e) {     rldatacontext dc = new rldatacontext();     this.dgvreports.datasource = dc.getreports(1);     this.dgvreports.databind(); }  protected void dgvreports_selectedindexchanged(object sender, eventargs e) {     if (this.dgvreports.selectedindex >= 0)     {         report rpt = (report)this.dgvreports.selectedrow.dataitem;     } } 

the return type of getreports isingleresult<report>

use bindingsource between datagridview , list. when selection made datagridview use bindingsource's current property right item list.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -