在转发器控制中维护不同页面上的选中值 [英] Maintain checked values across different pages in repeater control

查看:65
本文介绍了在转发器控制中维护不同页面上的选中值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a Datalist Control, where there are multiple rows(3 rows per page).Each row has a checkbox as well. My requirement is that I want the checked items to come down in the Repeater control when I press the "Checkout" Button. But when I go to the next page the checked items on the previous page gets reset.





我尝试过的方法:





What I have tried:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MaintainScrollPositionOnPostback="true" %>
<!DOCTYPE html>
    <title>DL-A1    
        <div>
            <asp:DataList ID="DataList1" runat="server" DataKeyField="bookid">
                <itemtemplate> 
<table><tbody><tr><td>
 </td><td>
                                Title: <%# Eval("booktit") %><br>
                                Author: <%# Eval("bookaut") %><br>
                                Publisher: <%# Eval("bookpub") %><br>
                                Prc: <%# Eval("bookprc") %><br>
                                <asp:CheckBox ID="CheckBox1" runat="server" Text="Buy" Font-Bold="True" /><br>
                            </td></tr></tbody></table>               
            
            <asp:Repeater ID="rptPaging" runat="server" OnItemCommand="rptPaging_ItemCommand">
                <itemtemplate>
                    <asp:LinkButton ID="lnkPage" runat="server" CommandName="Page" CommandArgument="<%# Container.DataItem %>"><%# Container.DataItem %>               
            
            <br>
            <asp:Label ID="lbl1" runat="server" Text="Label" Font-Bold="True">
            <br>
            <br>
            <asp:Button ID="Button1" runat="server" Text="Checkout" OnClick="extractCheckedVal" Font-Bold="True" Font-Size="X-Large" /><br><br><br>

            <asp:Repeater ID="Repeater1" runat="server">
                <headertemplate>
                    Total number of checked items: <%= v_tot %> <br>
                    Selected Items Are: 
                
                <itemtemplate>             
                         
                    <table><tbody><tr><td>                                
                            </td><td>
                                Title: <%# Eval("booktit") %><br>
                                Author: <%# Eval("bookaut") %><br>
                                Publisher: <%# Eval("bookpub") %><br>
                                Prc: <%# Eval("bookprc") %><br>                                
                            </td></tr></tbody></table>
                        
        </div>

推荐答案

这是转发器控件的工作方式,

如果你需要保持状态,你将不得不将当前页面检查的值存储到会话[页码,检查项目ID],然后在每个页面上数据绑定事件,您将不得不查看会话表示存储的值并进行相应的检查。
This is how the repeater control works,
if you need to maintain the state, you will have to store the current page checked values into a session [ page number, checked items id ], then on each page data bind event you will have to look into the session for the stored values and check it accordingly.


这篇关于在转发器控制中维护不同页面上的选中值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆