how to control a data before show with repeater???
-
Hi all, I have a problem when show data in repeater control. I want to control data(ex: check is Null OR ="") before show in webpage like: Name: <%#Container.DataItem("Name")%> Email: <%#Container.DataItem("Email")%> When data in <%#Container.DataItem("Email")%> is Null(=""), it's show: Name: XYZ Email: I want to show like Name: XYZ Email: none Please help, thanks for any response.
-
Hi all, I have a problem when show data in repeater control. I want to control data(ex: check is Null OR ="") before show in webpage like: Name: <%#Container.DataItem("Name")%> Email: <%#Container.DataItem("Email")%> When data in <%#Container.DataItem("Email")%> is Null(=""), it's show: Name: XYZ Email: I want to show like Name: XYZ Email: none Please help, thanks for any response.
Hi. You could do it using a custom function in your databinding syntax. Something like:
string FormatBlankAsNone(string sValue) { if (sValue == "") return "none"; else return sValue; }
Name: <%#Container.DataItem("Name")%>
Email: <%# FormatBlankAsNone(Container.DataItem("Email")) %>You probably need to modify this if DBNull is a legitamate value for your field, but the same idea should work.
-
Hi all, I have a problem when show data in repeater control. I want to control data(ex: check is Null OR ="") before show in webpage like: Name: <%#Container.DataItem("Name")%> Email: <%#Container.DataItem("Email")%> When data in <%#Container.DataItem("Email")%> is Null(=""), it's show: Name: XYZ Email: I want to show like Name: XYZ Email: none Please help, thanks for any response.
You can use the onItemDataBound event in the codeBehind. Private Sub rptList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptList.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then if DataBinder.Eval(e.Item.DataItem, "network").ToString.lenght > o then 'do something else ' do something else End If End If Hope that helps