Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I have written this but dont know how to bind with radio button date time picker etc
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
SqlConnection con = new SqlConnection("data source=.; database=HMS; integrated Security=SSPI");
SqlDataAdapter adp = new SqlDataAdapter("select * from Doctor where Doctorid='" + dataGridView1.CurrentRow.Cells["Doctorid"].Value + "'", con);
DataSet ds = new DataSet();
adp.Fill(ds,"Doctor");

txtDoctorId.Text = ds.Tables["Doctor"].Rows[0]["Doctorid"].ToString();
txtFirstName.Text = ds.Tables["Doctor"].Rows[0]["Dfname"].ToString();
txtMiddleName.Text = ds.Tables["Doctor"].Rows[0]["Dmname"].ToString();
txtLastName.Text = ds.Tables["Doctor"].Rows[0]["Dlname"].ToString();
string message = null;
if (ds.Tables["Doctor"].Rows[0]["Dgender"].ToString() == "male")
{
message = "male";
}
else
{
message = "female";
}
rdoMale.Text = ds.Tables["Doctor"].Rows[0]["Dgender"].ToString();
rdbFemale.Text = ds.Tables["Doctor"].Rows[0]["Dgender"].ToString();
 
txtPhoneNumber.Text = ds.Tables["Doctor"].Rows[0][""].ToString();
txtMobileNumber.Text = ds.Tables["Doctor"].Rows[0][""].ToString();
txtAddress.Text = ds.Tables["Doctor"].Rows[0][""].ToString();
txtEmailId.Text = ds.Tables["Doctor"].Rows[0][""].ToString();
txtSpecialization.Text = ds.Tables["Doctor"].Rows[0][""].ToString();

 

 
}
Posted 13-Dec-12 10:15am
Comments
Member 9581488 at 13-Dec-12 15:31pm
   
For radiobutton:
if(ds.Tables["Doctor"].Rows[0]["Dgender"].ToString()== "Male")
{
rdoMale.checked=true;
}

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You should fix this code, because it's putting all the data layer stuff right there in the presentation layer. If every method has a connection and a connection string, how do you manage when that string changes ?
 
As someone said, you turn the values coming from the DB in to values that are appropriate, like bools for radio buttons.
 
Try to have a subject line for your question that explains the NATURE of the question, but is not the whole question.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 320
1 Sergey Alexandrovich Kryukov 222
2 OriginalGriff 155
3 Peter Leow 115
4 Afzaal Ahmad Zeeshan 114
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 5,044
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 13 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100