I have column for Name, Date and another one for Time. If the values of date and Time columns are null or empty, how do I get to still show the label value in null data value?
Is this Possible? please how can I do that?. Here is what I mean in the table.
IdtypeEventNameDatedTimedLocation1EventArts Exhibition13-Mar-2303:00PM2 king Avenue2Visit permitVisitor8 plane str. From the table above, the type, Event has value in Dated and Timed columns, while Visit permit does not have any value in the Date and the timed columns.
My Code to display from database onto the label controls
string connectionString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
using (SqlConnection con = new SqlConnection(connectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand
{
CommandText = "SELECT * FROM TicketTable WHERE EventName = '" + Session["index"] + "'",
Connection = con
};
SqlDataAdapter sda = new SqlDataAdapter();
DataSet ds = new DataSet();
sda.SelectCommand = cmd;
sda.Fill(ds, "detail");
if (ds.Tables[0].Rows.Count > 0)
{
Title.Text = ds.Tables[0].Rows[0]["EventName"].ToString();
datelbl.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["Dated"]).ToLocalTime().ToString("MMM d, yyyy");
timelbl.Text = ds.Tables[0].Rows[0]["Timed"].ToString();
venuelbl.Text = ds.Tables[0].Rows[0]["Location"].ToString();
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Record not found');", true);
}
}