Exemple #1
0
        protected void RemoveBtnLink_Click(object sender, EventArgs e)
        {
            LinkButton  lb    = (LinkButton)sender;
            GridViewRow gvRow = (GridViewRow)lb.NamingContainer;
            int         rowID = gvRow.RowIndex;

            if (ViewState["AddTable"] != null)
            {
                DataTable dt = (DataTable)ViewState["AddTable"];
                if (dt.Rows.Count > 1)
                {
                    if (gvRow.RowIndex < dt.Rows.Count - 1)
                    {
                        //Remove the Selected Row data
                        dt.Rows.Remove(dt.Rows[rowID]);
                    }
                }
                //Store the current data in ViewState for future reference
                ViewState["AddTable"] = dt;
                //Re bind the GridView for the updated data
                AddQuestionGrid.DataSource = dt;
                AddQuestionGrid.DataBind();
            }

            //Set Previous Data on Postbacks
            SetPreviousData();
        }
Exemple #2
0
        private void InitialAddQuestion()
        {
            int       temp = 0;
            DataTable dt   = new DataTable();
            DataRow   dr   = null;

            int result = dbmanager.GetCountAllQuestion();

            if (result > 0)
            {
                temp = result + 1;
            }

            dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
            dt.Columns.Add(new DataColumn("Question", typeof(string)));
            dt.Columns.Add(new DataColumn("QuestionInclude", typeof(bool)));
            dt.Columns.Add(new DataColumn("RateOne", typeof(string)));
            dt.Columns.Add(new DataColumn("RateSeven", typeof(string)));
            dr = dt.NewRow();

            dr["RowNumber"]       = temp;
            dr["Question"]        = string.Empty;
            dr["QuestionInclude"] = true;
            dr["RateOne"]         = string.Empty;
            dr["RateSeven"]       = string.Empty;
            dt.Rows.Add(dr);

            //Store the DataTable in ViewState for future reference

            ViewState["AddTable"] = dt;

            //Bind the Gridview
            AddQuestionGrid.DataSource = dt;
            AddQuestionGrid.DataBind();
            TextBox box1 = (TextBox)AddQuestionGrid.Rows[0].Cells[1].FindControl("QuestionTbx");

            box1.Focus();

            TextBox box2 = (TextBox)AddQuestionGrid.Rows[0].Cells[2].FindControl("RateOneTbx");
            TextBox box3 = (TextBox)AddQuestionGrid.Rows[0].Cells[3].FindControl("RateSevenTbx");

            box2.Focus();
            box3.Focus();

            Session["temp"] = temp;
            IncludeLbl.Text = "*Include Qn: Checked indicates you would want to include the question to the staff peer evaluation exercise.";
        }
Exemple #3
0
        private void AddNewRowToGrid()
        {
            try
            {
                int temp     = (int)Session["temp"];
                int rowIndex = 0;

                if (ViewState["AddTable"] != null)
                {
                    DataTable dtCurrentTable = (DataTable)ViewState["AddTable"];
                    DataRow   drCurrentRow   = null;

                    if (dtCurrentTable.Rows.Count > 0)
                    {
                        for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
                        {
                            //extract the TextBox values

                            TextBox  box1 = (TextBox)AddQuestionGrid.Rows[rowIndex].Cells[1].FindControl("QuestionTbx");
                            TextBox  box2 = (TextBox)AddQuestionGrid.Rows[0].Cells[2].FindControl("RateOneTbx");
                            TextBox  box3 = (TextBox)AddQuestionGrid.Rows[0].Cells[3].FindControl("RateSevenTbx");
                            CheckBox chk1 = (CheckBox)AddQuestionGrid.Rows[rowIndex].Cells[4].FindControl("QnInclude");

                            drCurrentRow = dtCurrentTable.NewRow();
                            drCurrentRow["RowNumber"] = i + temp;

                            dtCurrentTable.Rows[i - 1]["Question"]        = box1.Text;
                            dtCurrentTable.Rows[i - 1]["RateOne"]         = box2.Text;
                            dtCurrentTable.Rows[i - 1]["RateSeven"]       = box3.Text;
                            dtCurrentTable.Rows[i - 1]["QuestionInclude"] = chk1.Checked;

                            rowIndex++;
                        }

                        dtCurrentTable.Rows.Add(drCurrentRow);
                        ViewState["AddTable"] = dtCurrentTable;

                        AddQuestionGrid.DataSource = dtCurrentTable;
                        AddQuestionGrid.DataBind();
                        TextBox bb = (TextBox)AddQuestionGrid.Rows[rowIndex].Cells[1].FindControl("QuestionTbx");
                        bb.Focus();
                        TextBox bb2 = (TextBox)AddQuestionGrid.Rows[rowIndex].Cells[2].FindControl("RateOneTbx");
                        TextBox bb3 = (TextBox)AddQuestionGrid.Rows[rowIndex].Cells[3].FindControl("RateSevenTbx");
                        bb2.Focus();
                        bb3.Focus();
                    }
                }

                else
                {
                    Response.Write("ViewState is null");
                }

                //Set Previous Data on Postbacks
                SetPreviousData();
            }
            catch (Exception ex)
            {
                MessageBoxShow(ex.Message);
            }
        }