Enable paging in listview when the listview is disabled. ASP.NET C#

remzi23

New Member
I have a button (Bearbeitung_Click) to disable/enable my listview which has batch inline editing. This is so that it is not always editable. I want the DataPager in the LayoutTemplate to be constantly enabled so that even when editing is disabled the user can still browse through the pages.My .aspx code for the template containing the datapager is:\[code\] <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>\[/code\]my code behind for the button and changing the page size is:\[code\] 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"; } }\[/code\]I have tried Datapager.Enabled = true; and variations of this but to no success. It doesn't seem top have an enabled property.
 
Back
Top