评论会员:游客 时间:2012/02/06
imgsrc=]:乌玛・尚卡尔帕特尔
protected void Page_Load(object sender, EventArgs e)
{
try
{
string selectSQL = "select name,gender,Designation,Deptt,Location,dob,emailid from empbirth where userid='" + txtempcode.Text + "'";
SqlCommand cmd = new SqlCommand(selectSQL, cnn);
SqlDataReader dr;
cnn.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
txtname.Text = dr[0].ToString();
txtgender.Text = dr[1].ToString();
txtdesignation.Text = dr[2].ToString();
txtdepartment.Text = dr[3].ToString();
txtlocation.Text = dr[4].ToString();
txtdob.Text = dr[5].ToString();
txtEid.Text = dr[6].ToString();
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
评论会员:科技Digestified的 时间:2012/02/06
很简单
在pageload事件,你需要分配它的文本属性值,你要设置该文本框的值
评论会员:gladiatron 时间:2012/02/06
有初级教程ADO.NET和C#中的数据访问所有互联网数据负载...尝试它,我会...
欢呼声......