我在更新面板中有一个GridView。
GridView的样式设置使每个备用行的颜色不同。
当我在GridView上更改页面时,它会丢失备用行着色。保留所有其他样式。
如果我删除更新面板,GridView会在更改页面后保持备用行着色。
有没有人知道造成这种情况的原因或解决方法?
谢谢, 尼尔
编辑:
这是aspx代码
<div id="active-logbooks" class="tab-content clearfix">
<div class="left-column">
<asp:MultiView runat="server" ID="mlvLogbooks" >
<asp:View runat="server" ID="vActiveLogbooks">
<asp:GridView PagerSettings-Mode="NextPrevious" PagerSettings-Position="Top" PagerSettings-NextPageImageUrl="~/img/right-arrow.png" PagerSettings-PreviousPageImageUrl="~/img/left-arrow.png" AllowPaging="true" runat="server" ID="gvActiveLogbooks" PageSize="5" AutoGenerateColumns="false" CssClass="lesson stripe-me" OnRowDataBound="gvActiveLogbooks_RowDataBound" OnPageIndexChanging="gvActiveLogbooks_PageIndexChanging">
<Columns>
<asp:BoundField HeaderText="Logbook number" DataField="LogbookNumber" ItemStyle-CssClass="border" ItemStyle-Width="100" />
<asp:BoundField HeaderText="Origin" DataField="Origin" ItemStyle-CssClass="border" ItemStyle-Width="100" />
<asp:BoundField HeaderText="Order Reference" DataField="OrderReference" ItemStyle-CssClass="border" ItemStyle-Width="100" />
<asp:TemplateField HeaderText="Transfer Date">
<ItemTemplate>
<asp:Literal runat="server" ID="lblTransferDate" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink runat="server" ID="lnkTransferLogbook" CssClass="border" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<a href="javascript:__doPostBack('ctl00$MainMaster$gvActiveLogbooks','Page$Prev')" id="lnkGridviewPrev" runat="server" class="left-arrow">Previous</a><asp:Literal runat="server" ID="litBreaker" Text=" |" />
<a href="javascript:__doPostBack('ctl00$MainMaster$gvActiveLogbooks','Page$Next')" id="lnkGridviewNext" runat="server" class="right-arrow">Next</a>
</asp:View>
</asp:MultiView>
</div>
这是发生页面更改时调用的函数:
protected void gvActiveLogbooks_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
HideShowGridViewPagerLinks(e.NewPageIndex);
gvActiveLogbooks.DataSource = _logbooks;
gvActiveLogbooks.PageIndex = e.NewPageIndex;
gvActiveLogbooks.DataBind();
}
页面上没有任何地方可以对GridView行进行着色
protected void gvActiveLogbooks_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.DataRow)
return;
Literal transferLabel = (Literal)e.Row.Cells[(int)ActiveLogbookGridViewColumns.TransferDate].FindControl("lblTransferDate");
transferLabel.Text = _logbooks[e.Row.RowIndex].TransferDate.ToShortDateString();
HyperLink transferLink = (HyperLink)e.Row.Cells[(int)ActiveLogbookGridViewColumns.TransferLink].FindControl("lnkTransferLogbook");
transferLink.Text = TransferLinkText;
transferLink.NavigateUrl = "TransferLogbooks.aspx?id=" + Guid.NewGuid();
}
答案 0 :(得分:1)
我猜你的CSS类和回发之间的一些交互搞乱了这一点。如果切换到RowStyle
和AlternateRowStyle
代码(示例here),并使用这些代码上的CssClass
属性引用CSS类,会发生什么?