Tuesday, 15 July 2014

c# - How to dynamically use eval() -



c# - How to dynamically use eval() -

for(i=0;i<10;i++) { <%# eval(i.tostring()).tostring()%> }

how can utilize eval if don't know column name. (means if datatable column creating dynamically)

i creating datatable the dt.column.add() column name come database so dont know column name coming. now how can print in asp.net page. eval require string constant; <%# eval("column name").tostring()%>

a gridview much improve suited this, automatically generates columns info source.

you can loop through columns property of datatable , columnname property each column, cannot utilize foreach loop within of databinding tags (<%# %>).

here's how @ column names in code-behind:

datatable dt = new datatable(); //populate info table foreach (datacolumn col in dt.columns) { string columnname = col.columnname; }

you utilize in loop in repeater's item template, because aren't using databinding block (<%# %>) lose container.dataitem makes extremely difficult, if not impossible, render out info current item.

c# asp.net

No comments:

Post a Comment