コード例 #1
0
        private void BindList()
        {
            var           childs = EmployeeDataAccessLayer.GetAllEmployees();
            StringBuilder output = new StringBuilder();



            if (childs.Count > 0)
            {
                //if children are there append another list to the parent node
                output.Append("<ul id=\"sortable\" class=\"list-group ui-sortable \">");
                childs.ForEach(x =>
                {
                    var objList = new List <object>();
                    objList.Add(x.EmployeeId.ToString());
                    objList.Add(x.Name);

                    var resultString = string.Join(",", objList.Cast <string>());


                    output.AppendFormat("<li class=\"list-group-item ui-state-default ui-sortable-handle \" id=\"btn_{0} \"   onclick=\"javascript:loadDetails({0} )\"> <span class=\"ui-icon ui-icon-arrowthick-2-n-s\"></span><a href=\"#\">{1}</a>", x.EmployeeId, x.Name);
                    output.Append("</li>");
                });
                output.Append("</ul>");

                Literal1.Text = output.ToString();

                var lstName = EmployeeDataAccessLayer.GetAllEmployees();

                rptEmpName.DataSource = lstName;
                rptEmpName.DataBind();
            }
        }
コード例 #2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            List <string> lstEmployeeIdsToDelete = new List <string>();

            foreach (GridViewRow gridViewRow in GridView3.Rows)
            {
                if (((CheckBox)gridViewRow.FindControl("cbDelete")).Checked)
                {
                    string employeeId =
                        ((Label)gridViewRow.FindControl("lblEmployeeId")).Text;
                    lstEmployeeIdsToDelete.Add(employeeId);
                }
            }
            if (lstEmployeeIdsToDelete.Count > 0)
            {
                EmployeeDataAccessLayer.DeleteEmployees(lstEmployeeIdsToDelete);
                BindGridViewData();
                lblMessage.ForeColor = System.Drawing.Color.Navy;
                lblMessage.Text      = lstEmployeeIdsToDelete.Count.ToString() +
                                       " row(s) deleted";
            }
            else
            {
                lblMessage.ForeColor = System.Drawing.Color.Red;
                lblMessage.Text      = "No rows selected to delete";
            }
        }
コード例 #3
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditRow")
            {
                var rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;

                GridView1.EditIndex = rowIndex;
                BindGridViewData();
            }
            else if (e.CommandName == "DeleteRow")
            {
                System.Web.UI.ClientScriptManager cs = Page.ClientScript;

                EmployeeDataAccessLayer.DeleteEmployee(Convert.ToInt32(e.CommandArgument));

                BindGridViewData();
            }
            else if (e.CommandName == "CancelUpdate")
            {
                GridView1.EditIndex = -1;
                BindGridViewData();
            }

            else if (e.CommandName == "UpdateRow")
            {
                int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;

                int    employeeId = Convert.ToInt32(e.CommandArgument);
                string name       = ((TextBox)GridView1.Rows[rowIndex].FindControl("TextBox1")).Text;
                string gender     = ((DropDownList)GridView1.Rows[rowIndex].FindControl("DropDownList1")).SelectedValue;
                string city       = ((TextBox)GridView1.Rows[rowIndex].FindControl("TextBox3")).Text;

                EmployeeDataAccessLayer.UpdateEmployee(employeeId, name, gender, city);

                GridView1.EditIndex = -1;
                BindGridViewData();
            }
            else if (e.CommandName == "InsertRow")
            {
                string name   = ((TextBox)GridView1.FooterRow.FindControl("txtName")).Text;
                string gender = ((DropDownList)GridView1.FooterRow.FindControl("ddlInsertGender")).SelectedValue;
                string city   = ((TextBox)GridView1.FooterRow.FindControl("txtCity")).Text;

                EmployeeDataAccessLayer.InsertEmployee(name, gender, city);

                BindGridViewData();
            }
        }
コード例 #4
0
 private void BindGridViewData()
 {
     GridView1.DataSource = EmployeeDataAccessLayer.GetAllEmployees();
     GridView1.DataBind();
 }
コード例 #5
0
 public List <EmployeeDataAccessLayer.Employee> GetAllEmployeesJson(/*bool _search, int nd, int rows   , int page   , string sidx   , string sord*/)
 {
     return(EmployeeDataAccessLayer.GetAllEmployees());
 }