Dynamic column-label or linkbutton?

Discussion in 'ASP .Net Datagrid Control' started by Adam Smith, Jan 30, 2004.

  1. Adam Smith

    Adam Smith Guest

    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>


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Adam Smith, Jan 30, 2004
    #1
    1. Advertising

  2. Adam Smith

    Earl Teigrob Guest

    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


    "Adam Smith" <> wrote in message
    news:...
    >
    >
    > 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>
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Earl Teigrob, Jan 30, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QkxpVFpXaU5H?=

    Adding dynamic LinkButton to dynamic table

    =?Utf-8?B?QkxpVFpXaU5H?=, Jul 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    692
    =?Utf-8?B?QkxpVFpXaU5H?=
    Jul 27, 2005
  2. Sathyaish
    Replies:
    3
    Views:
    3,076
    Sathyaish
    Sep 8, 2005
  3. Replies:
    1
    Views:
    317
    bruce barker \(sqlwork.com\)
    Nov 10, 2006
  4. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    167
    Sathyaish
    Sep 8, 2005
  5. Knut Krueger
    Replies:
    8
    Views:
    237
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page