3
我有一個按鈕(Bearbeitung_Click)來禁用/啓用我的列表視圖,它具有批量行內編輯。這是這樣,它並不總是可編輯的。我希望LayoutTemplate中的DataPager始終處於啓用狀態,以便即使在禁用編輯時,用戶仍可以瀏覽頁面。禁用列表視圖時,在列表視圖中啓用分頁。 ASP.NET C#
我對含有DataPager的模板的.aspx代碼:
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" style="background-color: #E0FFFF;color: #333333; font-size:smaller;">
<th runat="server">
</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
<th runat="server">
Example</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server"
style="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF">
<asp:DataPager ID="DataPager1" runat="server" Enabled="true">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
我的代碼背後的按鈕,並改變頁面大小爲:
protected void PageSize_Changed(object sender, EventArgs e)
{
DataPager pager = ListView1.FindControl("DataPager1") as DataPager;
if (string.IsNullOrEmpty(tb_page.Text) || tb_page.Text == "0")
{
label.Text = "Number required";
}
else
{
/*pager.PageSize = Convert.ToInt32(page_size_dropdown.SelectedValue);*/
pager.PageSize = Convert.ToInt32(tb_page.Text);
label.Text = "";
}
}
protected void Bearbeitung_Click(object sender, EventArgs e)
{
DataPager pager = ListView1.FindControl("DataPager1") as DataPager;
if (ListView1.Enabled == true)
{
ListView1.Enabled = false;
cmdUpdate.Enabled = false;
btn_Bearbeitung.Text = "Bearbeitung";
cmdDelete.Enabled = false;
LinqDataSource1.DataBind();
ListView1.DataBind();
}
else
{
ListView1.Enabled = true;
cmdUpdate.Enabled = true;
cmdDelete.Enabled = true;
btn_Bearbeitung.Text = "Disable Editing";
}
}
我已經試過Datapager.Enabled =真正;和這種變化,但沒有成功。它似乎沒有啓用屬性。