Tuesday, 10 September 2013

control not working properly

control not working properly

I am trying to use the keydown feature .My code is up and running but am
getting this strange error.I am running a query where if in the database
column value is MIND then the radiobutton mind should be checked else
MSSL.but the control always goes into else part no matter ,the value in
the database is MIND or MSSL. Following is my code
private void txtlogin_userid_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (sender is TextBox)
{
TextBox txb = (TextBox)sender;
dc.SelectCommand = new SqlCommand("select * from UserMaster where
UserID='" + txb.Text + "'", sc);
dc.Fill(ds);
dg.DataSource = ds.Tables[0];
txtlogin_name.Text = ds.Tables[0].Rows[0][1].ToString();
txtlogin_mailid.Text = ds.Tables[0].Rows[0][2].ToString();
MessageBox.Show(ds.Tables[0].Rows[0][3].ToString());
string a = "MIND";
if (ds.Tables[0].Rows[0][3].ToString() == a)
{
radiomind.Checked = true;
}
else
{
radioMSSL.Checked = true;
}
}
}}
when i enter the any number that has MIND as its value in the database,the
message box shows MIND but still the control goes into else part and the
MSSL radio button activates.what to do?

No comments:

Post a Comment