Пример #1
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            DBConnect db           = new DBConnect();
            string    nationalcode = txtNationalCode.Value;//.TrimStart('0');
            string    firstname    = txtFirstName.Value;
            string    lastname     = txtLastName.Value;
            string    fathersname  = txtFathersName.Value;

            db.Connect();
            DataTable dt = db.Select("SELECT TOP 20 [id],[NationalCode],[FirstName],[LastName],[FathersName] " +
                                     "FROM [Personal] WHERE [NationalCode] LIKE '%" + nationalcode + "%' AND " +
                                     "[FirstName] LIKE N'%" + firstname + "%' AND [LastName] LIKE N'%" + lastname + "%' AND [FathersName] LIKE N'%" + fathersname + "%' " +
                                     "ORDER BY CAST([Created] AS NVARCHAR(10)) DESC");

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

            db.DisConnect();

            if (dt.Rows.Count == 0)
            {
                divNew.Style.Clear();
                Session["nationalcode"] = nationalcode;
                Session["firstname"]    = firstname;
                Session["lastname"]     = lastname;
                Session["fathersname"]  = fathersname;
            }
        }
Пример #2
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        /// <param name="text">The text.</param>
        void BindGrid(string text)
        {
            if (String.IsNullOrEmpty(ClassName))
            {
                return;
            }

            int total = 0;

            GridMain.DataSource = genSource(text, out total);
            GridMain.DataBind();

            foreach (GridViewRow gvr in GridMain.Rows)
            {
                ImageButton btn = (ImageButton)gvr.FindControl("btnSave");
                btn.Attributes.Add("onclick", String.Format("javascript:MC_SELECT_POPUPS['{2}'].selectObject('{0}', '{1}');", _ownerControl, btn.CommandArgument, this.ClientID));
                btn.Style.Add("display", "none");
            }
            lblTotalCount.Text = "<b>Total:</b> " + total + " items.";
        }