Click here to Skip to main content
13,298,361 members (55,390 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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();

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";
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
Member 9581488 13-Dec-12 15:31pm
For radiobutton:
if(ds.Tables["Doctor"].Rows[0]["Dgender"].ToString()== "Male")

1 solution

Rate this: bad
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171207.1 | Last Updated 13 Dec 2012
Copyright © CodeProject, 1999-2017
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