HI,
In the following code i am comaparing two string values. Let say count2 has the value 17 and texpdate.Text has 17. eventhough it is executing else block. Let me know where is error
if (Convert.ToString(count2.ToString())==texpdate3.Text)
{
TextBox texpdate2 = GridView1.FooterRow.FindControl("txtexpdate") as TextBox;
TextBox tpos = GridView1.FooterRow.FindControl("txtpos") as TextBox;
TextBox tmfg_date2 = GridView1.FooterRow.FindControl("txtmfgdate") as TextBox;
SqlConnection conn = new SqlConnection(cs);
conn.Open();
SqlCommand cmd = new SqlCommand("insert into Sva_units Values(@Product_name,@expiry_date,@position,@mfg_date,@Machine_num)", conn);
cmd.Parameters.AddWithValue("@Product_name", ddl_pname.SelectedValue);
cmd.Parameters.AddWithValue("@expiry_date", texpdate2.Text);
cmd.Parameters.AddWithValue("@position", tpos.Text);
cmd.Parameters.AddWithValue("@mfg_date", tmfg_date2.Text);
cmd.Parameters.AddWithValue("@Machine_num", ddl_mnum.Text);
cmd.ExecuteNonQuery();
lblError.Text = "<br />Record inserted successfully<br />";
bind(); // rebind the data
//}
ddl_pname.SelectedValue = "";
ddl_mnum.SelectedValue = "";
}
else
{
Page.Controls.Add(new LiteralControl("<script>alert('Position shoud be in order!.');</script>"));
}