9/24/09

Get the answers...

Today i will write about how i get all the user answers  and store them in users_answers table:


    protected void saveAnswers()
    {
       if (IsPostBack)
       {


           clsDataAccess myclass = new clsDataAccess();
           myclass.openConnection();


           SqlCommand selectCMD = new SqlCommand("SELECT user_id, user_name, question_id, answer_id, answer_text FROM users_answers", myclass.getConn());
           selectCMD.CommandTimeout = 30;

           SqlDataAdapter users_answersDA = new SqlDataAdapter();
           users_answersDA.SelectCommand = selectCMD;

           DataSet users_answersDS = new DataSet();
                                
           users_answersDA.TableMappings.Add("Table", "users_answers");
           users_answersDA.Fill(users_answersDS, "users_answers");
          
           myclass.closeConnection();


           string strUserID = Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString();
           bool IsAnyAnswered = false;


           foreach (cQuestion oQuestion in Questions)
           {
               if (oQuestion.SaveAnswers(Request, users_answersDS.Tables["users_answers"], User.Identity.Name, strUserID))
                   IsAnyAnswered = true;

           }

         

           if (IsAnyAnswered)
           {


               MultiView1.ActiveViewIndex = 1;

           }
       }//end of save answers

I have put on the page the MultiView control to show the user the "Thank you"
After he had answered the questions





Download the soure link

No comments:

Post a Comment

Getting started with docker

It is very simple to get started usig docker. All you need to do-is download the docker desktop for your system Once you get docker syste...