By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,212 Members | 2,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,212 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!

Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
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
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.