1
嗨我想有一個DropDownList外的GridView,顯示頁碼列表。當用戶點擊頁碼時,GridView應該進入該頁面。我能夠填充DropDownList的,但它不是在GridViewGridView跳轉到頁面DropDownList
在這裏工作是我的GridView和DropDownList的
<asp:DropDownList ID="ddlPageNumber" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlPaging_SelectedIndexChanged">
</asp:DropDownList> of
<%=GridView1.PageCount%>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" BorderStyle="Solid" GridLines="Both" HeaderStyle-BackColor="#990033" Width="1000px"
DataSourceID="EntityDataSource1" OnRowDataBound="GridView1_RowDataBound" OnDataBound="GridView1_DataBound">
<HeaderStyle ForeColor="White"></HeaderStyle>
<Columns>
<asp:BoundField DataField="intBatchID" HeaderText="Batch ID" ReadOnly="True"
SortExpression="intBatchID" />
<asp:BoundField DataField="vcharName" HeaderText="Name" ReadOnly="True"
SortExpression="vcharName" />
<asp:BoundField DataField="dtmScheduled" HeaderText="Date Scheduled"
ReadOnly="True" SortExpression="dtmScheduled" />
<asp:BoundField DataField="intBatchPriorityLevel"
HeaderText="Priority Level" ReadOnly="True"
SortExpression="intBatchPriorityLevel" />
</Columns>
<PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" PageButtonCount="4" PreviousPageText="Previous" NextPageText="Next" FirstPageText="First" LastPageText="Last" />
<PagerStyle HorizontalAlign="Center" />
</asp:GridView>
這裏的背後
protected void GridView1_DataBound(object sender, EventArgs e)
{
for (int cnt = 0; cnt < GridView1.PageCount; cnt++)
{
int curr = cnt + 1;
ListItem item = new ListItem(curr.ToString());
if (cnt == GridView1.PageIndex)
{
item.Selected = true;
}
ddlPageNumber.Items.Add(item);
}
}
protected void ddlPaging_SelectedIndexChanged(object sender, EventArgs e)
{
GridView1.PageIndex = ddlPageNumber.SelectedIndex;
}
我嘗試了數據綁定,它仍然沒有工作,但我意識到,NEIT她是我的pagesize下拉菜單,分頁工作也不在GridView內部。我收到錯誤消息無法在DropDownList中選擇多個項目。當我點擊數字分頁。任何想法? – hollyquinn
@hollyquinn - 你是否重新綁定每個「Page_Load」上的網格? –
卡爾不,我不是。我可以做? – hollyquinn