c# - Can you databind an asp.net gridview to a field in a base class? -


i have following classes (pseudocode):

  • item ( int field1 )
  • itemdetail : item (int field2, string field3)

if set itemdetail datasource asp.net gridview:

grid.datasource = new list<itemdetail>(); grid.databind(); 

can use field1 in gridview? if so, correct databinder syntax? following code blows trying cast item:

<%# databinder.eval(container.dataitem, "field1") %> 

thanks in advance help.

edit: , i'm moron. had copied gridview , calling rowdatabound event handler different grid... sorry have wasted everyones time, there info here regardless if has same question. in end, public properties of base class binding correctly. thanks!

if base class property public, shouldn't have issue long you're initializing in child constructors.

also, i'm not sure if example binding pseudocode or not, have bind grid ilistsource, ienumerable, or idatasource, need collection, list, iqueryable, etc. of itemdetails.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -