我有一个包含多个项目的下拉列表,并且用户保存了所有选定的值。但是当我试图从数据库中获取数据到下拉列表时。下拉列表显示的是初始值而不是数据库值。
<asp:DropDownList ID="ddimportance" Height="32" runat="server">
<asp:ListItem Text="High" Value="0"></asp:ListItem>
<asp:ListItem Text="Medium" Value="1"></asp:ListItem>
<asp:ListItem Text="Low" Value="2"></asp:ListItem>
<asp:ListItem Text="NA" Value="3"></asp:ListItem>
</asp:DropDownList>
using (SqlConnection con = new SqlConnection(st))
{
con.Open();
SqlCommand cmd = new SqlCommand("spGetUploadedImage", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PId", Convert.ToInt32(ddproject.SelectedValue.ToString()));
SqlDataReader rd = cmd.ExecuteReader();
if (rd.Read())
{
txtuserdomain.Text = rd["P_user_domain"].ToString();
txtawards.Text = rd["P_awards"].ToString();
txtcoverage.Text = rd["P_functional_coverage"].ToString();
txtfeatures.Text = rd["P_feature"].ToString();
txtimplementation.Text = rd["P_implementation"].ToString();
//lblimportance.Text = rd["Importance"].ToString();
//ddimportance.ClearSelection();
ddimportance.Items.FindByText(rd["Importance"].ToString()).Selected = true;}