当我点击gridview分页时,它隐藏了整个网格本身

时间:2017-02-17 19:12:53

标签: c# asp.net .net c#-3.0 c#-2.0

未使用更新面板,但内容页面中存在网格。当我点击分页中的任何页码时,总网格都是隐藏的。没有使用更新面板,但内容页面中存在网格。当我点击分页中的任何页码时,总网格隐藏:

<asp:GridView ID="GrdViewMasterTable" AutoGenerateColumns="false" runat="server"
        AutoGenerateEditButton="true" OnRowEditing="GrdViewMasterTable_RowEditing"
        OnRowUpdating="GrdViewMasterTable_RowUpdating"
        OnRowCancelingEdit="GrdViewMasterTable_RowCancelingEdit"
        AllowPaging="true"
        PageSize="15"
        OnPageIndexChanging="GrdViewMasterTable_PageIndexChanging"
        HorizontalAlign="Left"
        OnRowDataBound="GrdViewMasterTable_RowDataBound"
        OnRowDeleting="GrdViewMasterTable_RowDeleting"
        AutoGenerateDeleteButton="True"
        SkinID="GridViewList">
        <PagerSettings Mode="Numeric"
            Position="Bottom"
            PageButtonCount="10" />
        <PagerStyle CssClass="pager" HorizontalAlign="Center" />


    </asp:GridView>

当我点击分页中的任何页面编号时,总网格隐藏:

protected void GrdViewMasterTable_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    try
    {
        if (GrdViewMasterTable.EditIndex != -1)
        {
            string confirmValue = Request.Form["confirm_value"];
            if (confirmValue == "Yes")
            {
                Update();
                GrdViewMasterTable.PageIndex = e.NewPageIndex;
                GrdViewMasterTable.DataBind();
                //FillGridFromViewState();
                //FillGridFromDataTable();
            }
            else
            {
                e.Cancel = true;
            }
        }
        else
        {
            // Clear the error message.
            errorMessage = string.Empty;
            GrdViewMasterTable.PageIndex = e.NewPageIndex;

                GrdViewMasterTable.DataBind();


            //FillGridFromViewState();
            //FillGridFromDataTable();
        }
    }
    catch (Exception ex)
    {

        AlertMsg(ex.Message);
    }
}  

2 个答案:

答案 0 :(得分:0)

请尝试此article

CustomerGridView.PagerSettings.Visible = true;

答案 1 :(得分:0)

尝试下面的一个:

void GrdViewMasterTable_RowEditing(Object sender, GridViewEditEventArgs e)
  {
    // Hide the pager row.
    GrdViewMasterTable.PagerSettings.Visible = true;
  }