Exemplo n.º 1
0
    private void DataBindAll()
    {
        string condition;

        string ProSeries = TxtProSeries.Text.Trim() == "" ? " and 1=1 " : " and PS_Name like '%" + TxtProSeries.Text.Trim() + "%' ";
        string PTName    = TxtProType.Text.Trim() == "" ? " and 1=1 " : " and PT_Name like '%" + TxtProType.Text.Trim() + "%' ";
        string PTCode    = TxtProCode.Text.Trim() == "" ? " and 1=1 " : " and PT_Code like '%" + TxtProCode.Text.Trim() + "%' ";;

        condition = ProSeries + PTName + PTCode;
        try
        {
            Grid_ProType.DataSource = pbInfo.SearchPBTypeInfo(condition);
        }
        catch (Exception)
        {
            throw;
        }

        Grid_ProType.DataBind();
        UpdatePanel_ProType.Update();
    }
Exemplo n.º 2
0
    protected void Grid_ProType_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView theGrid      = sender as GridView; // refer to the GridView
        int      newPageIndex = 0;

        if (-2 == e.NewPageIndex)
        { // when click the "GO" Button
            TextBox     txtNewPageIndex = null;
            GridViewRow pagerRow        = Grid_ProType.BottomPagerRow;


            if (null != pagerRow)
            {
                txtNewPageIndex = (TextBox)pagerRow.FindControl("textbox");   // refer to the TextBox with the NewPageIndex value
            }

            if (null != txtNewPageIndex && txtNewPageIndex.Text != "")
            {
                newPageIndex = int.Parse(txtNewPageIndex.Text) - 1; // get the NewPageIndex
            }
        }
        else
        {  // when click the first, last, previous and next Button
            newPageIndex = e.NewPageIndex;
        }

        // check to prevent form the NewPageIndex out of the range


        //绑定数据源
        //bindgridview1();
        newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
        newPageIndex = newPageIndex >= Grid_ProType.PageCount ? Grid_ProType.PageCount - 1 : newPageIndex;
        // specify the NewPageIndex
        Grid_ProType.PageIndex = newPageIndex;
        DataBindAll();

        Grid_ProType.SelectedIndex = -1;
        UpdatePanel_ProType.Update();
    }