Esempio n. 1
0
        private void button7_Click(object sender, EventArgs e)
        {
            DataTable dt = (DataTable)GridViewList.DataSource;
            DataRow   dr = dt.NewRow();

            dt.Rows.Add(dr);
            GridViewList.ClearSelection();
            GridViewList.CurrentCell = GridViewList.Rows[GridViewList.Rows.Count - 1].Cells[0];

            DataTable dt2 = (DataTable)GridViewColumns.DataSource;

            dt2.Rows.Clear();
            txtName.Text        = "";
            txtCommandText.Text = "";
            txtCaption.Text     = "";
            txtCategory.Text    = "";
            txtXMLName.Text     = "";

            txtcolName.Text          = "";
            txtcolCaption.Text       = "";
            txtcolType.Text          = "";
            txtcolWidth.Text         = "";
            txtcolDefaultValue.Text  = "";
            txtcolDataSource.Text    = "";
            txtcolValueMember.Text   = "";
            txtcolDisplayMember.Text = "";
            txtcolFooterName.Text    = "";
            txtcolFooterType.Text    = "";;
        }
        protected void UpdateList()
        {
            DataColumn dc;

            dt = new DataTable();
            dc = new DataColumn("firstName");
            dt.Columns.Add(dc);
            dc = new DataColumn("lastName");
            dt.Columns.Add(dc);
            dc = new DataColumn("gender");
            dt.Columns.Add(dc);
            dc = new DataColumn("email");
            dt.Columns.Add(dc);
            dc = new DataColumn("city");
            dt.Columns.Add(dc);

            dt.Rows.Add("Selva", "Kumar", "Male", "*****@*****.**", "Hyderabad");
            dt.Rows.Add("Mithilesh", "Kumar", "Male", "*****@*****.**", "Bangalore");
            dt.Rows.Add("Aqib", "Shehzad", "Male", "*****@*****.**", "Chennai");
            dt.Rows.Add("Sonu", "Chowdary", "Female", "*****@*****.**", "Hyderabad");
            dt.Rows.Add("Vignesh", "Mani", "Male", "*****@*****.**", "Chennai");

            ds.Tables.Add(dt);
            GridViewList.DataSource = ds.Tables[0];

            GridViewList.DataBind();
            Session["EmpList"] = dt;
            Session["elist"]   = null;
        }
        protected void OnDelete(object sender, EventArgs e)
        {
            GridViewRow row = (sender as LinkButton).NamingContainer as GridViewRow;
            DataTable   dt  = Session["EmpList"] as DataTable;

            dt.Rows.RemoveAt(row.RowIndex);
            Session["EmpList"]      = dt;
            GridViewList.DataSource = dt;

            GridViewList.DataBind();
        }
    protected void GridViewList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string        id        = GridViewList.Rows[e.RowIndex].Cells[0].Text.ToString();
        string        sqlstr    = "update applicant set deleteFlag='true' where applicantID='" + id + "'";
        string        conString = System.Configuration.ConfigurationManager.ConnectionStrings["GrnetConnectionString"].ToString(); //连接数据库字符串
        SqlConnection Conn      = new SqlConnection(conString);                                                                    //连接数据库

        Conn.Open();
        SqlCommand comm = new SqlCommand(sqlstr, Conn);

        comm.ExecuteNonQuery();
        GridViewList.DataBind();
        Response.Redirect("applicantList.aspx");
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string         conString = System.Configuration.ConfigurationManager.ConnectionStrings["GrnetConnectionString"].ToString(); //连接数据库字符串
         SqlConnection  Conn      = new SqlConnection(conString);                                                                    //连接数据库
         string         sqlStr    = "SELECT * FROM applicant where deleteFlag = 'false'";
         SqlDataAdapter Da        = new SqlDataAdapter(sqlStr, Conn);                                                                //打开数据库
         DataSet        Ds        = new DataSet();
         Da.Fill(Ds);
         GridViewList.DataSource = Ds.Tables[0];
         GridViewList.DataBind();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(IsPostBack))
            {
                if (Session["elist"] != null)
                {
                    UpdateList();
                    if (Session["Data"] == null)
                    {
                        dt = (DataTable)Session["EmpList"];
                        GridViewList.DataSource = dt;

                        GridViewList.DataBind();
                    }
                    else
                    {
                        dt = (DataTable)Session["EmpList"];

                        dt1 = (DataTable)Session["Data"];
                        dt.Rows.Add(dt1.Rows[0][0], dt1.Rows[0][1], dt1.Rows[0][2], dt1.Rows[0][3], dt1.Rows[0][4]);
                        GridViewList.DataSource = dt;

                        GridViewList.DataBind();
                        Session.Remove("Data");
                    }
                }
                else
                {
                    if (Session["Data"] == null)
                    {
                        dt = (DataTable)Session["EmpList"];
                        GridViewList.DataSource = dt;

                        GridViewList.DataBind();
                    }
                    else
                    {
                        dt = (DataTable)Session["EmpList"];

                        dt1 = (DataTable)Session["Data"];
                        dt.Rows.Add(dt1.Rows[0][0], dt1.Rows[0][1], dt1.Rows[0][2], dt1.Rows[0][3], dt1.Rows[0][4]);
                        GridViewList.DataSource = dt;

                        GridViewList.DataBind();
                        Session.Remove("Data");
                    }
                }
            }
        }
Esempio n. 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     GridViewList.DataSource = _cotext.GetItems().ToList();
     GridViewList.DataBind();
 }