Monday, March 26, 2012

Text if not null

I want to display text in a datagrid based on if the text pulled in from the database is null or not.

Below I can change the backcolor if its not blank but I want to change the text :

Put "Confirmed" if it is not null, and "Not Confirmed" if it is null.

Dim conf As String
conf = Convert.ToString(DataBinder.Eval(e.Item.DataItem, "confirm_id"))

If conf <> "" Then
e.Item.BackColor = System.Drawing.Color.AliceBlue

End If

How can I do this?Try (3 is just an example, you'll have to use the right column index)
e.Item.Cells[3].Text = "Confirmed"

Regards
Fredr!k
I got the following error:
'Cells' is not a member of 'System.Web.UI.WebControls.DataListItem'.

I am using a datalist is there a way of doing this with a datalist?

0 comments:

Post a Comment