コード例 #1
0
    protected void SearchEvent(object sender, EventArgs e)
    {
        string  SearchQuery = "SELECT * FROM View_Companydetails WHERE View_Companydetails.CompanyName LIKE '" + TBSearch.Text.Trim() + "%'";
        DataSet DSRecord    = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.Text, SearchQuery);

        if (DSRecord.Tables[0].Rows.Count > 0)
        {
            GVCompany.DataSource = DSRecord.Tables[0];
            GVCompany.DataBind();
        }
        else
        {
            GVCompany.EmptyDataText = "No Record Found !";
            GVCompany.DataBind();
        }
        foreach (GridViewRow Row in GVCompany.Rows)
        {
            Label      lblStatus = (Label)Row.FindControl("lblStatus");
            LinkButton LBEdit    = (LinkButton)Row.FindControl("LBEdit");
            LinkButton LBDelete  = (LinkButton)Row.FindControl("LBDelete");
            if (lblStatus.Text == "Active")
            {
                lblStatus.CssClass = "label label-success";
                LBEdit.Enabled     = true;
                LBDelete.Enabled   = true;
            }
            else
            {
                lblStatus.CssClass = "label label-danger";
                LBEdit.Enabled     = false;
                LBDelete.Enabled   = false;
            }
        }
    }
コード例 #2
0
    private void BindGVCompany()
    {
        string  SelectQuery = "SELECT * FROM View_Companydetails";
        DataSet DSRecord    = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.Text, SelectQuery);

        if (DSRecord.Tables[0].Rows.Count > 0)
        {
            GVCompany.DataSource = DSRecord.Tables[0];
            GVCompany.DataBind();
        }
        else
        {
            GVCompany.EmptyDataText = "No Record Found !";
            GVCompany.DataBind();
        }
        foreach (GridViewRow Row in GVCompany.Rows)
        {
            Label      lblStatus = (Label)Row.FindControl("lblStatus");
            LinkButton LBEdit    = (LinkButton)Row.FindControl("LBEdit");
            LinkButton LBDelete  = (LinkButton)Row.FindControl("LBDelete");
            if (lblStatus.Text == "Active")
            {
                lblStatus.CssClass = "label label-success";
                LBEdit.Enabled     = true;
                LBDelete.Enabled   = true;
            }
            else
            {
                lblStatus.CssClass = "label label-danger";
                LBEdit.Enabled     = false;
                LBDelete.Enabled   = false;
            }
        }
    }
コード例 #3
0
        public void FetchCompany()
        {
            CompanyDAL CompDAL = new CompanyDAL {
                ConnectionString = ConfigurationManager.ConnectionStrings["MySQLTest"].ToString()
            };

            GVCompany.DataSource = CompDAL.GetCompany(null);
            GVCompany.DataBind();
        }
コード例 #4
0
        public void FillGrid()
        {
            try
            {
                DataTable dt_ = new DataTable();
                //dt_ = DBConnection.GetQueryData("select rtrim('[' + CAST(ProductTypeID AS VARCHAR(200)) + ']-' + ProductTypeName ) as [ProductTypeName], ProductTypeID from tbl_Companies");
                dt_ = DBConnection.GetQueryData("select CompanyId, Name from tbl_Companies");

                GVCompany.DataSource = dt_;
                GVCompany.DataBind();
                ViewState["Company"] = dt_;
            }
            catch (Exception ex)
            {
                //   throw;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true);
                lblalert.Text = ex.Message;
            }
        }
コード例 #5
0
 private void SearchRecord()
 {
     try
     {
         FillGrid();
         DataTable _dt = (DataTable)ViewState["Company"];
         DataView  dv  = new DataView(_dt, "Name LIKE '%" + TBSearchCompany.Text.Trim().ToUpper() + "%'", "[Name] ASC", DataViewRowState.CurrentRows);
         DataTable dt_ = new DataTable();
         dt_ = dv.ToTable();
         GVCompany.DataSource = dt_;
         GVCompany.DataBind();
         ViewState["Company"] = dt_;
     }
     catch (Exception ex)
     {
         //   throw;
         ScriptManager.RegisterStartupScript(this, this.GetType(), "isActive", "Alert();", true);
         lblalert.Text = ex.Message;
     }
 }
コード例 #6
0
 protected void GVCompany_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     GVCompany.PageIndex = e.NewPageIndex;
     BindGVCompany();
     GVCompany.DataBind();
 }