datagrid itemtemplate help

Discussion in 'ASP .Net Datagrid Control' started by angus, Jun 16, 2004.

  1. angus

    angus Guest

    Dear All,

    In my datagrid, i want to add a logic to it. that is, if the result for the
    data equals to "Yes",
    a "asp:label" control will be displayed; otherwise a "asp:imagebutton"
    control will be shown

    <ItemTemplate>
    <% if DataBinder.Eval(Container.DataItem, "boflag").equals("Yes") then%>
    <asp:Label id="Label1" runat="server" Text='<%#
    DataBinder.Eval(Container.DataItem,"boflag")%>'></asp:Label>
    <% Else %>
    <asp:imagebutton id="imgBtnUpdate" runat="server" NAME="Imagebutton3"
    ImageUrl="no.gif"></asp:imagebutton>
    <% end if %>
    </ItemTemplate>

    However, "<% if DataBinder.Eval(Container.DataItem,
    "boflag").equals("Yes") then%> " this is not valid.

    So, how can i get the data to compare the value.

    Thank you.

    Regards,
    Angus
    angus, Jun 16, 2004
    #1
    1. Advertising

  2. angus

    Rick Spiewak Guest

    You can do this in the codebehind in the itemdatabound event. Put both
    controls in the template, then in the code set one to visible, the other not
    visible.

    "angus" <> wrote in message
    news:...
    > Dear All,
    >
    > In my datagrid, i want to add a logic to it. that is, if the result for

    the
    > data equals to "Yes",
    > a "asp:label" control will be displayed; otherwise a "asp:imagebutton"
    > control will be shown
    >
    > <ItemTemplate>
    > <% if DataBinder.Eval(Container.DataItem, "boflag").equals("Yes")

    then%>
    > <asp:Label id="Label1" runat="server" Text='<%#
    > DataBinder.Eval(Container.DataItem,"boflag")%>'></asp:Label>
    > <% Else %>
    > <asp:imagebutton id="imgBtnUpdate" runat="server"

    NAME="Imagebutton3"
    > ImageUrl="no.gif"></asp:imagebutton>
    > <% end if %>
    > </ItemTemplate>
    >
    > However, "<% if DataBinder.Eval(Container.DataItem,
    > "boflag").equals("Yes") then%> " this is not valid.
    >
    > So, how can i get the data to compare the value.
    >
    > Thank you.
    >
    > Regards,
    > Angus
    >
    >
    >
    Rick Spiewak, Jun 20, 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. angus

    datagrid itemtemplate help

    angus, Jun 16, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    3,996
    Eliyahu Goldin
    Jun 16, 2004
  2. VB Programmer
    Replies:
    6
    Views:
    563
    VB Programmer
    Sep 1, 2004
  3. Bennett Haselton
    Replies:
    1
    Views:
    5,328
    Joe Fallon
    Sep 24, 2004
  4. Craig
    Replies:
    1
    Views:
    3,532
  5. VB Programmer

    Urgent help with ItemTemplate (datagrid) - databound DropDownList

    VB Programmer, Sep 1, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    6
    Views:
    162
    VB Programmer
    Sep 1, 2004
Loading...

Share This Page