2011-09-28 37 views
-2

我有一个5步向导控件。 用户从Drop Downlist,TextBoxes中选择他的值后,我有一个submit_click事件来将所有选定的值插入到数据库中。asp.net向导控件

下面是我在Submit_Click

try 
       { 

        int result = new objBLL.PostProfile 
        { 
         ProfileId = 1, 
         CasteId = Convert.ToInt32(casteDropDown.SelectedValue), 
         MMBId = iMMBID, 
         UserId = UserId, 
         FullName = Full_Name.Text, 
         Gender = genderDropDown.SelectedValue, 
         Age = Convert.ToInt32(Age.Text), 
         Height = HeightDropDown.SelectedValue, 
         Complexion = ComplexionDropDown.SelectedItem.ToString() 
}.Save(Operation.Insert); 

public class PostProfile 
    { 
     PostProfileDAL objProfileDAL = new PostProfileDAL(); 

     public int ProfileId { get; set; } 
     public int CasteId { get; set; } 
     public int MMBId { get; set; } 
     public Guid UserId { get; set; } 
     public string FullName { get; set; } 
     public string Gender { get; set; } 
     public int Age { get; set; } 
     public string Height { get; set; } 
     public string Complexion { get; set; } 

public int Save(Operation opr) 
     { 
      int result = 0; 
      SqlParameter[] parms = { 
             new SqlParameter("@Profile_Id", ProfileId), 
             new SqlParameter("@Caste_Id", CasteId), 
             new SqlParameter("@MMB_Id", MMBId), 
             new SqlParameter("@User_ID", UserId), 
             new SqlParameter("@Full_Name", FullName), 
             new SqlParameter("@Gender", Gender), 
             new SqlParameter("@Age", Age), 
             new SqlParameter("@Height", Height), 
             new SqlParameter("@Complexion", Complexion) 

            }; 

      try 
      { 
       if (opr == Operation.Insert) 
       { 

        result = DALBASE.SetData("InsertProfileDetails", parms); 
} 

catch (Exception ex) 
      { 
       result = 1; 
       throw ex; 
      } 

因此,这是我遇到的麻烦。 将所有数据发送到.cs文件时,它能够保留所有文本框值,但是保留了下拉列表框中的所有选定值。

例如:对于DropDownlist肤色,如果我在向导控件中选择值“VeryFair”, 将它发送到保存操作的类文件,则肤色下拉列表的值仍为“请选择一个值”

任何帮助表示赞赏 感谢 孙

回答

0

检查你的向导的ViewStateMode属性。

它应该被启用而不是继承。