I am displaying my table values in the Gridview, In database in the status column i am storing the values as 'Y' and 'N' for 'Active' and 'Inactive' respectively. But while showing in the Gridview i want to show status as Active and InActive and not as Y and N.
<asp:Label ID="lblmerstatus" runat="server" Text= '<%# DataBinder.Eval(Container, "DataItem.STATUS") == "Y" ? "Active" : "InActive"%>'></asp:Label>
But its always showing me only InActive even when the status is Y . Please help
use this may be this will help you
<asp:Label ID="lblmerstatus" runat="server" Text'<%# Convert.ToBoolean(Eval("Status")) %>'
Text='<%# Eval("Status").ToString().Equals("True") ? "Active" : "InActive" %>' />
Try using
<asp:Label ID="lblmerstatus" runat="server"
Text= '<%# DataBinder.Eval(Container, "STATUS").ToString() == "Y" ? "Active" : "InActive"%>' ></asp:Label>
Now use this may be this will help you...
Solution 1 : If your table field "STATUS" return Boolean value like true(1) or false(0):
<asp:Label ID="Label1" runat="server" Text='<%# Convert.ToBoolean(Eval("STATUS")) == true ? "Active" : "InActive" %>'></asp:Label>
Solution 2 : If your table field "STATUS" return string value like Y or N:
<asp:Label ID="Label1" runat="server" Text='<%# Convert.ToString(Eval("STATUS")) == "Y" ? "Active" : "InActive" %>'></asp:Label>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.