本文介绍了单击gridview后如何显示数据内容应显示在文本框,radiobutton,datetimepicker和listview中的数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写过这个,但不知道如何绑定单选按钮日期时间选择器等

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]。值+'',con);

DataSet ds = new DataSet();

adp .Fill(ds,Doctor);



txtDoctorId.Text = ds.Tables [Doctor]。行[0] [Doctorid]。ToString ();

txtFirstName.Text = ds.Tables [Doctor]。行[0] [Dfname]。ToString();

txtMiddleName.Text = ds.Tables [Doctor]。行[0] [Dmname]。ToString();

txtLastName.Text = ds.Tables [Doctor]。行[0] [ Dlname]。ToString();

string message = null;

if(ds.Tables [Doctor]。行[0] [Dgender]。ToString()==male)

{

message =male;

}

else

{

message =female;

}

rdoMale.Text = ds.Tables [Doctor]。行[0] [Dgender]。ToString( );

rdbFemale.Text = ds.Tables [Doctor]。行[0] [Dgender]。ToString();



txtPhoneNumber.Text = ds.Tables [Doctor]。行[0] []。ToString();

txtMobileNumber.Text = ds.Tables [Doctor]。行[0] []。ToString();

txtAddress.Text = ds.Tables [Doctor]。行[0] []。ToString();

txtEmailId.Text = ds.Tables [Doctor]。行[0] []。ToString();

txtSpecialization.Text = ds.Tables [Doctor ] .Rows [0] []。ToString();









}

解决方案

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();




}

解决方案


这篇关于单击gridview后如何显示数据内容应显示在文本框,radiobutton,datetimepicker和listview中的数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 05:20