I have posts made by users, but my challenge is this, if there is no post made by users the broken image control and lable still shows on
page making my page to look horrible. So the idea is to check if PostId in database exist if not exist hide panel 1 and panel2, the reason for hidding
panel is because i have to put these control in panels so that it will be easier for me to hid them all.
System.Text.StringBuilder sb = new System.Text.StringBuilder();
SqlConnection conne = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
string constrr = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
string con;
DataTable dt;
// int id;
// private string constr = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
static string username = string.Empty;
static int Id = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
if (!this.IsPostBack)
{
username = this.Page.User.Identity.Name;
DataTable dt = GetProfile();
GetMergedAll.DataSource = dt;
ViewState["DataTable"] = dt;
GetMergedAll.DataSource = dt;
GetMergedAll.DataBind();
// if (dt.Rows.Count > 0)
{
}
}
}
}
public DataTable GetProfile()
{
SqlConnection constr = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
SqlDataAdapter adp = new SqlDataAdapter("GetUserPOSTS", constr);
adp.SelectCommand.CommandType = CommandType.StoredProcedure;
// adp.SelectCommand.Parameters.AddWithValue("@Email", username);
adp.SelectCommand.Parameters.AddWithValue("@UserName", username);
adp.SelectCommand.Parameters.AddWithValue("@Id", Id);
DataTable dt = new DataTable();
//
adp.Fill(dt);
return dt;
}
here is the two panels
PANEL 1
PANEL2