我在不同的页面上有两个gridviews,代码几乎相同,一个正在工作,但另一个没有......
这是不工作的代码:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true" EnablePartialRendering= "true">
</asp:ScriptManager>
<div id="gridview">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" style="font-family: Verdana, Arial, Sans-Serif;"
DataKeyNames="id"
CssClass="gridview" BackColor="#CCCCCC"
BorderStyle="Inset" BorderWidth="2px" BorderColor="GrayText"
CellPadding="1"
CellSpacing="5"
HeaderStyle-HorizontalAlign="Center"
OnRowDataBound="GridView1_RowDataBound"
ForeColor ="Black" RowStyle-CssClass="gridview"
OnRowCommand="GridView1_RowCommand"
ViewStateMode="Enabled" AllowPaging="True"
OnPageIndexChanging="GridView1_PageIndexChanging" PageSize="3">
<AlternatingRowStyle BackColor="LightGray" />
<columns>
<asp:BoundField HeaderText="ID" DataField="id" />
<asp:BoundField HeaderText="PRIORIDADE" DataField="prioridade"
ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="SITUAÇÃO" DataField="situacao"
ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="RESPONSAVEL" DataField="responsavel"
HeaderStyle-Width="65px" ItemStyle-HorizontalAlign="Center" >
<HeaderStyle Width="65px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="DATA DE CADASTRO" DataField="dt_cadastro"
DataFormatString="{0:dd/MM/yyyy}" HeaderStyle-Width="60px"
ItemStyle-HorizontalAlign="Center" >
<HeaderStyle Width="60px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="PREVISÃO DE TÉRMINO" DataField="previsao_termino"
DataFormatString="{0:dd/MM/yyyy}" HeaderStyle-Width="80px"
ItemStyle-HorizontalAlign="Center" >
<HeaderStyle Width="80px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="PROJETO" DataField="projeto"
ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="FUNCIONALIDADE" DataField="funcionalidade"
ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="CLUBE" DataField="clube"
ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderStyle-Width="70px" HeaderText="VISUALIZAR" >
<ItemTemplate>
<asp:Button ID="Btn_Visualizar" runat="server" Text="VISUALIZAR" CssClass="Btn_Grid" Font-Size="7pt" Font-Names="Verdana, Arial"
CommandName="visualizar" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" />
</ItemTemplate>
<HeaderStyle Width="70px" />
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="66px" HeaderText="ALTERAR">
<ItemTemplate>
<asp:Button ID="Btn_Alterar" runat="server" Text="ALTERAR" CssClass="Btn_Grid" Font-Size="7pt" Font-Names="Verdana, Arial"
CommandName="editar" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" />
</ItemTemplate>
<HeaderStyle Width="66px" />
</asp:TemplateField>
</columns>
<EditRowStyle ForeColor="Black" CssClass="GridViewEditRow" />
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" BorderColor="White" BorderStyle="Solid" BorderWidth="1px" />
<PagerStyle BackColor="#6600FF" ForeColor="Black" HorizontalAlign="Left"
Font-Size="8pt" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
这是我的codebehind
:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["login"] == null)
{
Response.Redirect("~/Login.aspx");
}
else
{
if (!Page.IsPostBack)
{
GridView1.DataSource = _ch.BuscaChamadosAtivos();
GridView1.DataBind();
}
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = _ch.BuscaChamadosAtivos();
GridView1.DataBind();
}
即使numbers of the pagging
没有出现...
Obs:其中两个字段将ALWAYS
变为空......这可能会导致我这个问题吗?我不这么认为……但我还是说了。