日期:2014-05-18  浏览次数:20480 次

dropdownlist取值问题,求教!谢谢
我从图书列表编辑那里转到编辑页面,其中有两个值是显示在下拉列表的,但是只有第一个正确显示,第二个就只显示第一行了,为什么,求助指导,谢谢了

设计界面:有两个dropdownlist控件,分别图书编辑传递过来的值,图书分类和出版社
  所属丛书分类:<asp:DropDownList ID="BookTypeDDList" runat="server" ></asp:DropDownList><br /><br />
  图书出版社:<asp:DropDownList ID="PublishDDList" runat="server"></asp:DropDownList><br /> <br />
后台代码如下:
protected void Page_Load(object sender, EventArgs e)
  {
  if (!Page.IsPostBack)
  {
  DDListBind();//绑定下拉列表
   
  int Id = Convert.ToInt32(Request.QueryString["BookId"]);


  SqlConnection BookConn = new SqlConnection();
  BookConn.ConnectionString = ConfigurationManager.ConnectionStrings["conn"].ToString();
  BookConn.Open();

  SqlCommand BookCmd = new SqlCommand("select * from Books where Id =" + "'" + Id + "'", BookConn);
  SqlDataAdapter BookDataAdapter = new SqlDataAdapter(BookCmd);
  DataSet BookDataSet = new DataSet();
  BookDataAdapter.Fill(BookDataSet, "BookTable");
  BookConn.Close();
  this.txtId.Text = BookDataSet.Tables["BookTable"].Rows[0][0].ToString();
  this.txtTitle.Text = BookDataSet.Tables["BookTable"].Rows[0][1].ToString();
  this.txtAuthor.Text = BookDataSet.Tables["BookTable"].Rows[0][2].ToString();
  this.PublishDDList.SelectedValue = BookDataSet.Tables["BookTable"].Rows[0][3].ToString();
  this.txtPubdate.Text = BookDataSet.Tables["BookTable"].Rows[0][4].ToString();
  this.txtISBN.Text = BookDataSet.Tables["BookTable"].Rows[0][5].ToString();
  this.txtWordCount.Text = BookDataSet.Tables["BookTable"].Rows[0][6].ToString();
  this.txtUnitePrice.Text = BookDataSet.Tables["BookTable"].Rows[0][7].ToString();
  this.txtBookInfo.Text = BookDataSet.Tables["BookTable"].Rows[0][8].ToString();
  this.txtAuthorDesc.Text = BookDataSet.Tables["BookTable"].Rows[0][9].ToString(); 
  this.BookTypeDDList.SelectedValue = BookDataSet.Tables["BookTable"].Rows[0][12].ToString();
   
   
  }
   
  }
   
  private void DDListBind()//从数据库中取得数据源,绑定到下拉列表方法
  {
  //新建一个连接实例
  SqlConnection DDLConn = new SqlConnection();
  //从Web.config文件获取数据库连接字符串
  DDLConn.ConnectionString = ConfigurationManager.ConnectionStrings["conn"].ToString();
  DDLConn.Open();

  SqlCommand CategoryCmd = new SqlCommand("SELECT * FROM Categories", DDLConn);
  SqlDataAdapter CategoryDataAdapter = new SqlDataAdapter(CategoryCmd);

  SqlCommand Publishcmd = new SqlCommand("SELECT * FROM Publishers", DDLConn);
  SqlDataAdapter PublishDataAdapter = new SqlDataAdapter(Publishcmd);
  DataSet DDLDataSet = new DataSet();
  CategoryDataAdapter.Fill(DDLDataSet, "CategoriesTable");
  PublishDataAdapter.Fill(DDLDataSet, "PublisherTable");

   
  this.BookTypeDDList.DataTextField = "Name";
  this.BookTypeDDList.DataValueField = "