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

L

Lars Netzel

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
 
G

Guest

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
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top