html
<asp:FormView ID="userprofile" runat="server" Width="100%" >
<ItemTemplate>
<asp:Panel ID="PLNHid" runat="server">
<asp:Label ID="lblName" runat="server" Text='<%# Eval("Status") %>' ForeColor="Black" Font-Size="X-Large" Font-Bold="True">
</asp:Panel>
<asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' ForeColor="Black" Font-Size="X-Large" Font-Bold="True">
</asp:Label>
</ItemTemplate>
</asp:FormView>
code
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (this.Page.User.Identity.IsAuthenticated)
{
string username = this.Page.User.Identity.Name;
GetProfile(username);
}
}
}
public void GetProfile(string username)
{
string str = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
string getADPOST = "GetUSERPRO2";
using (SqlConnection con = new SqlConnection(str))
{
con.Open();
using (SqlCommand cmd = new SqlCommand(getADPOST, con))
{
cmd.CommandType = CommandType.StoredProcedure;
//cmd.Parameters.AddWithValue("@Name", Request.QueryString["Id"].ToString());
cmd.Parameters.AddWithValue("@FriendUserName", Request.QueryString["Id"].ToString());
cmd.Parameters.AddWithValue("@UserName", Request.QueryString["Id"].ToString());
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable ds = new DataTable();
da.Fill(ds);
userprofile.DataSource = ds;
userprofile.DataBind();
}
}
}
// I want to fine turn this code to make it hid panel if Status in table is empty
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (!string.IsNullOrEmpty((e.Item.FindControl("lblSTATUS") as Label).Text))
{
(e.Item.FindControl("PLNHid") as Panel).Visible = true;
}
else
{
(e.Item.FindControl("PLNHid") as Panel).Visible = false;
}
}
See table diagram
ID USERNAME STATUS
------------------------------------------
1 Mic34 1
------------------------------------------
2 steve
------------------------------------------
3 Dav344 1
------------------------------------------
So looking at the table you can see that steve status is empty so on page the panel holding status lable will be hidden