我有一个按钮 (Bearbeitung_Click) 来禁用/启用具有批量内联编辑的列表视图。这是因为它并不总是可编辑的。我希望 LayoutTemplate 中的 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 = true; 和这种变化,但没有成功。它似乎没有启用的属性。