Click here to Skip to main content
15,890,973 members

Comments by karthik reddy mereddy (Top 9 by date)

karthik reddy mereddy 24-Sep-13 6:36am View    
it is a datagridview, even though there is no data in the datagridview, we can select the cells.
karthik reddy mereddy 19-Sep-13 6:15am View    
Was it the same you are referring to:?


private void btnInsert_Click(object sender, EventArgs e)
{
if (txtName.Text == string.Empty)
{
MessageBox.Show("Please enter a value to Project Name!");
txtName.Focus();
return;
}
if (txtContactPerson.Text == string.Empty)
{
MessageBox.Show("Please enter a value to Description!");
txtContactPerson.Focus();
return;
}
SqlConnection con = Helper.getconnection();
con.Open();
try
{
string commandText = "InsertClient";
SqlCommand cmd = new SqlCommand(commandText, con);
cmd.Parameters.AddWithValue("@Name", txtName.Text);
cmd.Parameters.AddWithValue("@ContactPerson", txtContactPerson.Text);
cmd.CommandType = CommandType.StoredProcedure;

MessageBox.Show("Client details are inserted successfully");
txtName.Clear();
txtContactPerson.Clear();

object Name = cmd.ExecuteNonQuery();
BindData();
}
catch (Exception ex)
{

MessageBox.Show(ex.Message);

}
finally
{
con.Close();
}
}
karthik reddy mereddy 12-Sep-13 2:26am View    
Actually, by using "blank space i the string" it is taking that space as value and displaying as null, but actually it is not becoming Null.
karthik reddy mereddy 12-Sep-13 2:25am View    
If we use dateTimePicker1.CustomFormat = " "; the control is becoming null and on submitting it is taking the default value. My requirement is it should give a error message and should not accept the Null value.
karthik reddy mereddy 11-Sep-13 6:36am View    
I am sorry for the typo, I am using if (dateInsert.Value.ToString() == string.Empty).
When the page is loading it is coming with the todays date in datetimepicker control. What requieremnt is, I should definitely click or change the date to previous on the datetimepicker control in order to submit.