我必须将更改审核到数据库中。在大多数页面上,这都很完美,因为只有文本框 - 但是在我现在正在处理的页面上,使用下拉列表,我的代码不起作用。
<td>
<asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="SqlDatacountry" DataTextField="country_name" DataValueField="country_id">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDatacountry" runat="server" ConnectionString="<%$ ConnectionStrings:songtypecons %>" SelectCommand="SELECT * FROM [country_detail]"></asp:SqlDataSource>
</td>
后面的代码:
string sql1 = "selectcust_fname,cust_mname,cust_lname,cust_birthdate,cust_gender,cust_address,cust_contact_num,cust_country,cust_state,cust_city,cust_zip from cust_detail where cust_id ='" + ds.Tables["filldata"].Rows[0].ItemArray[0].ToString() + "' ";
SqlDataAdapter adpt1 = new SqlDataAdapter(sql1, con);
DataSet ds1 = new DataSet();
adpt1.Fill(ds1, "custdata");
if (ds1.Tables["custdata"].Rows.Count > 0)
{
for (int d = 0; d < DropDownList4.Items.Count; d++)
{
if (ds1.Tables["custdata"].Rows[0].ItemArray[7].ToString() == DropDownList4.Items[d].Text)
{
DropDownList4.Items[d].Selected = true;
break;
}
}
}