示例#1
0
        protected void AttributeOptions_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                SetRowData();
                if (ViewState["CurrentTable"] != null)
                {
                    DataTable dt           = (DataTable)ViewState["CurrentTable"];
                    DataRow   drCurrentRow = null;
                    int       rowIndex     = Convert.ToInt32(e.RowIndex);
                    if (dt.Rows.Count > 1)
                    {
                        dt.Rows.Remove(dt.Rows[rowIndex]);
                        drCurrentRow = dt.NewRow();
                        ViewState["CurrentTable"]   = dt;
                        AttributeOptions.DataSource = dt;
                        AttributeOptions.DataBind();

                        for (int i = 0; i < AttributeOptions.Rows.Count - 1; i++)
                        {
                            AttributeOptions.Rows[i].Cells[0].Text = Convert.ToString(i + 1);
                        }
                        SetPreviousData();
                    }
                }
            }
            catch (Exception exc)
            {
                LogUtils.myLog.Info(exc, exc);
            }
        }
示例#2
0
        private void FirstGridViewRow()
        {
            DataTable dt = new DataTable();
            DataRow   dr = null;

            dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
            dt.Columns.Add(new DataColumn("Col1", typeof(string)));
            dt.Columns.Add(new DataColumn("Col2", typeof(string)));

            dr = dt.NewRow();
            dr["RowNumber"] = 1;
            dr["Col1"]      = string.Empty;
            dr["Col2"]      = string.Empty;
            dt.Rows.Add(dr);

            ViewState["CurrentTable"] = dt;

            AttributeOptions.DataSource = dt;
            AttributeOptions.DataBind();

            TextBox txn = (TextBox)AttributeOptions.Rows[0].Cells[2].FindControl("priorityNo");

            txn.Focus();
            Button btnAdd = (Button)AttributeOptions.FooterRow.Cells[1].FindControl("ButtonAdd");

            Page.Form.DefaultFocus = btnAdd.ClientID;
        }
示例#3
0
        private void FirstGridViewRow(int inputId)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
            dt.Columns.Add(new DataColumn("Col1", typeof(string)));
            dt.Columns.Add(new DataColumn("Col2", typeof(string)));

            List <QueAttributeOption> queAttrOptionList = queDaoObj.getOptionsListByAttributeID(inputId);
            int rowCount = 0;

            foreach (QueAttributeOption option in queAttrOptionList)
            {
                DataRow dr = null;
                dr = dt.NewRow();
                dr["RowNumber"] = rowCount + 1;
                dr["Col1"]      = option.priorityOption;
                dr["Col2"]      = option.optionStatement;
                dt.Rows.Add(dr);

                rowCount++;
            }

            ViewState["CurrentTable"]   = dt;
            AttributeOptions.DataSource = dt;
            AttributeOptions.DataBind();

            for (int count = 0; count < rowCount; count++)
            {
                TextBox TextBoxName = (TextBox)AttributeOptions.Rows[count].Cells[2].FindControl("txtName");
                TextBoxName.Text = queAttrOptionList[count].optionStatement;
                TextBox PriorityTextBox = (TextBox)AttributeOptions.Rows[count].Cells[1].FindControl("priorityNo");
                PriorityTextBox.Text = queAttrOptionList[count].priorityOption;
            }

            TextBox txn = (TextBox)AttributeOptions.Rows[0].Cells[1].FindControl("priorityNo");

            txn.Focus();
            Button btnAdd = (Button)AttributeOptions.FooterRow.Cells[1].FindControl("ButtonAdd");

            Page.Form.DefaultFocus = btnAdd.ClientID;
        }
示例#4
0
        private void AddNewRow()
        {
            int rowIndex = 0;

            if (ViewState["CurrentTable"] != null)
            {
                DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
                DataRow   drCurrentRow   = null;
                if (dtCurrentTable.Rows.Count > 0)
                {
                    for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
                    {
                        TextBox TextBoxName         = (TextBox)AttributeOptions.Rows[rowIndex].Cells[2].FindControl("txtName");
                        TextBox priorityTextBoxName = (TextBox)AttributeOptions.Rows[rowIndex].Cells[2].FindControl("priorityNo");
                        drCurrentRow = dtCurrentTable.NewRow();
                        drCurrentRow["RowNumber"] = i + 1;

                        dtCurrentTable.Rows[i - 1]["Col1"] = priorityTextBoxName.Text;
                        dtCurrentTable.Rows[i - 1]["Col2"] = TextBoxName.Text;
                        rowIndex++;
                    }

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

                    AttributeOptions.DataSource = dtCurrentTable;
                    AttributeOptions.DataBind();

                    TextBox txn = (TextBox)AttributeOptions.Rows[rowIndex].Cells[2].FindControl("priorityNo");
                    txn.Focus();
                }
            }
            else
            {
                Response.Write("ViewState is null");
            }
            SetPreviousData();
        }
        private void FirstGridViewRow()
        {
            QueQuestion ques1 = new QueQuestion()
            {
                questionId        = 112,
                questionStatement = "This is question One"
            };

            QueQuestion ques2 = new QueQuestion()
            {
                questionId        = 2,
                questionStatement = "This is question Two"
            };


            questionList.Add(ques1);
            questionList.Add(ques2);

            Session["questionList"] = questionList;

            AttributeOptions.DataSource = questionList;
            AttributeOptions.DataBind();
        }