Adding Logic including Container.DataItem in the HTML code of DataGrid??

Discussion in 'ASP .Net' started by Lars Netzel, May 14, 2004.

  1. Lars Netzel

    Lars Netzel Guest

    Why Can't I use something like this?

    <%# If Container.DataItem("id") = 0 then%>
    bla bla bla
    <%end if%>

    I've been messing around with a IIF statement as well but it does'nt do it
    for me either!

    /Lars
    Lars Netzel, May 14, 2004
    #1
    1. Advertising

  2. Hi, Lar

    In HTML code, you can only do some simple databinding. If you want to do more, do it in code-behind
    For datagrid, wrap the logic in ItemDataBound event
    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBoun
    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem The
    If Container.DataItem("id") = 0 the
    'Do stuff you like
    End I
    End I
    End Su

    Bin Song, MCP
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, May 14, 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. Lauchlan M
    Replies:
    1
    Views:
    7,232
    Lauchlan M
    Oct 15, 2003
  2. Tom Lee
    Replies:
    2
    Views:
    835
    Chris Carter
    Dec 9, 2003
  3. anony
    Replies:
    1
    Views:
    456
    =?Utf-8?B?QmFycnkgRm9ycmVzdA==?=
    Feb 19, 2004
  4. Earl Teigrob
    Replies:
    0
    Views:
    445
    Earl Teigrob
    Jul 7, 2004
  5. Joe Rattz
    Replies:
    2
    Views:
    596
    Robert Koritnik
    Sep 10, 2004
Loading...

Share This Page