我有一個網格視圖,並設置允許頁面爲true.it工作正常,但是當我想隱藏某些列(如ID)時,頁碼被隱藏!網格視圖的頁碼被隱藏在RowDataBound
<asp:GridView ID="gvVisa" OnRowDataBound="gvVisa_RowDataBound" OnSelectedIndexChanged="gvVisa_SelectedIndexChanged" OnPageIndexChanging="gvVisa_PageIndexChanging" runat="server" AllowPaging="True" PageSize="5" AutoGenerateColumns="False" Font-Size="13px" Width="963px">
<AlternatingRowStyle BackColor="#00CCFF" ForeColor="#333333" HorizontalAlign="Center" VerticalAlign="Middle" BorderStyle="None" />
<Columns>
<asp:BoundField HeaderText="شناسه" DataField="vsiId"></asp:BoundField>
<asp:TemplateField HeaderText="تصویر ">
<ItemStyle Width="150" />
<ItemTemplate>
<asp:Image ID="Image3" runat="server" ImageUrl='<%#Eval("visImageName") %>' Width="150" Height="100" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText=" نام کشور" ItemStyle-Width="600px" DataField="visCountry">
<ItemStyle Width="600px"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="وضعیت نمایش " DataField="isActive"></asp:BoundField>
<asp:TemplateField HeaderText="وضعیت نمایش">
<ItemStyle Width="100px" />
<ItemTemplate>
<asp:Image ID="Image1" Width="24px" Height="24px" ImageUrl="~/images/false.png" Visible='<%# !(bool)Eval("isActive") %>' runat="server" />
<asp:Image ID="Image2" Width="24px" Height="24px" ImageUrl="~/images/true.png" Visible='<%# Eval("isActive") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="عملیات">
<ItemStyle Width="100px" />
<ItemTemplate>
<asp:LinkButton Text="تغییر وضعیت" Width="100px" CssClass="btns" ID="lnkSelect" runat="server" CommandName="Select" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" BackColor="#333333" ForeColor="White" />
<RowStyle BackColor="White" ForeColor="#333333" HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:GridView>
結合DB:
protected void Page_Load(object sender, EventArgs e)
{
gvVisa.DataSource = from q in new Data.TouristDataContext().Visas select q;
gvVisa.DataBind();
}
頁索引改變事件:
protected void gvVisa_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvVisa.PageIndex = e.NewPageIndex;
}
和行數據綁定事件無形一些列:
protected void gvVisa_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].Visible = false;
}
我怎麼能解決這個問題?
有你再在頁面索引綁定小時gridview的改變 –
或者你可以簡單地設置在ASPX本身可見假的,因爲我看到有隱藏 –