I wrote a code in the page load to check whether lblName.Text is empty or not.
Now the only code that works is the part where the lblName.Text is not empty, the part where the label is empty does not work
i mean the label is not editable again.
My code below
public partial class Default14 : System.Web.UI.Page
{
SqlCommand cmd1 = new SqlCommand();
SqlCommand cmd = new SqlCommand();
SqlConnection dbConn = new SqlConnection();
SqlConnection dbConn1 = new SqlConnection();
SqlConnection dbConn2 = new SqlConnection();
SqlDataReader dr, dr2, dr1, dr3;
string selectSQL, updateSQL, selectSQL1;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (lblName.Text == "")
{
lblName.Text = !string.IsNullOrEmpty(lblName.Text) ? lblName.Text : " ";
}
else
{
string selectSQL = "SELECT machine FROM job where id ='11'";
SqlConnection con = new SqlConnection();
con.ConnectionString = "data source=NERO-SIGBENU\\SQLEXPRESS01; Initial Catalog=arpackaging;Integrated Security=True;";
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = selectSQL;
cmd.CommandType = CommandType.Text;
try
{
con.Open();
string name = Convert.ToString(cmd.ExecuteScalar());
lblName.Text = name;
}
catch (Exception err)
{
Response.Write(err.ToString());
}
finally
{
con.Close();
}
}
}
}
}
please help