Dynamic column-label or linkbutton?

A

Adam Smith

How do I dynamically decide on a column type depending upon my data.
I.E., what I want to do is (But get a compile error in browser on syntax
of missing '}'):

<asp:TemplateColumn HeaderText="MyColumn">
<ItemTemplate>
<%# String if(DataBinder.Eval(Container,
"DataItem.MyColmn")==null){ %>
<asp:label id=label1 runat=server text="nodata"/>
<% }else{%>
<asp:ButtonColumn Text="Jump to Data" CommandName="Jump"/>
<% }%>
</ItemTemplate>
</asp:TemplateColumn>
 
E

Earl Teigrob

I could not find a a way of doing this AND maintianing view state without
creating a Custom Column Control and either modifying its controls visible
property in the itemDataBound event or using DataBinding Data to
conditionally load controls within the custom colomn control itself. Chaper
12 of "ASP.NET Data Web Controls" by Scott Mitchell explains Custom Columns
very well.

Earl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top