本文介绍了此代码是否适用于通过下拉列表更新值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! protected void DropDownList1_SelectedIndexChanged(对象发件人,EventArgs e) { SqlDataAdapter ds = new SqlDataAdapter( 从emp_deatils中选择*,其中emp_name =' + DropDownList1.Text + ',conn); DataTable dt = new DataTable(); ds.Fill(dt); TextBox_father_name.Text = dt.Rows [ 0 ] [ 1 ]。ToString(); TextBox_Age.Text = dt.Rows [ 0 ] [ 2 ]。ToString(); RadioButtonList_sex.Text = dt.Rows [ 0 ] [ 3 ]。ToString(); TextBox_dob.Text = dt.Rows [ 0 ] [ 4 ]。ToString(); TextBox_nationality.Text = dt.Rows [ 0 ] [ 5 ]。ToString(); TextBox_state.Text = dt.Rows [ 0 ] [ 6 ]。ToString(); TextBox_city.Text = dt.Rows [ 0 ] [ 7 ]。ToString(); TextBox_mob.Text = dt.Rows [ 0 ] [ 8 ]。ToString(); DropDownList_exp.Text = dt.Rows [ 0 ] [ 9 ]。ToString(); DropDownList_qual.Text = dt.Rows [ 0 ] [ 10 ]。ToString(); TextBox_sal.Text = dt.Rows [ 0 ] [ 11 ]。ToString(); TextBox_email.Text = dt.Rows [ 0 ] [ 12 ]。ToString(); DropDownList1.DataBind(); } 此代码是否正确通过下拉列表更新值...通过选择下拉列表中的项目我希望在d尊重文本框和单选按钮中拥有所有d值..但无法实现它.... ?? 解决方案 Quote:这段代码是否正确通过下拉列表更新值 你是决定这一点的最佳人选:-) 确保你已经在DropDownList的aspx页面中将autopostback设置为true,然后执行选定的索引更改, < asp:DropDownList AutoPostBack = True put b在事件内部重新点,并检查您收到的值DropDownList1.Text,并检查运行时中的最终sql语句。如果它是正确的,你可以检查作为数据表返回的数据以及问题在哪里。 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { SqlDataAdapter ds = new SqlDataAdapter("Select * from emp_deatils where emp_name='"+DropDownList1.Text+"' ", conn); DataTable dt = new DataTable(); ds.Fill(dt); TextBox_father_name.Text = dt.Rows[0][1].ToString(); TextBox_Age.Text = dt.Rows[0][2].ToString(); RadioButtonList_sex.Text = dt.Rows[0][3].ToString(); TextBox_dob.Text = dt.Rows[0][4].ToString(); TextBox_nationality.Text = dt.Rows[0][5].ToString(); TextBox_state.Text = dt.Rows[0][6].ToString(); TextBox_city.Text = dt.Rows[0][7].ToString(); TextBox_mob.Text = dt.Rows[0][8].ToString(); DropDownList_exp.Text = dt.Rows[0][9].ToString(); DropDownList_qual.Text = dt.Rows[0][10].ToString(); TextBox_sal.Text = dt.Rows[0][11].ToString(); TextBox_email.Text = dt.Rows[0][12].ToString(); DropDownList1.DataBind(); }Is this code correct for updating values through dropdownlist...by selecting an item in the dropdown list i want to have all d values in d respectv textboxes and radiobutton ..but unable to achieve it....?? 解决方案 Quote:Is this code correct for updating values through dropdownlistyou are the best person to decide that :-)make sure that you have put autopostback as true in your aspx page for the DropDownList, then selected index change will be executed,<asp:DropDownList AutoPostBack="True"put break point inside the event and check the values you receive as DropDownList1.Text and also check the final sql statement in the runtime. if it is correct you can check the data returned as datatable and where is the issue. 这篇关于此代码是否适用于通过下拉列表更新值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 19:50