将控件的数据从转发器传输到另一页 [英] Transfer data of a control from repeater to another page

查看:68
本文介绍了将控件的数据从转发器传输到另一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想将数据从转发器控件中的控件(例如标签控件)传输到另一个页面。

我尝试使用session但是,不可能。请帮忙。

谢谢。

Hi all,
I want to transfer data from a control (e.g. a label control) that is in a repeater control to another page.
I tried using session, but couldn''t. Please help with it.
Thank you.

推荐答案

http://stackoverflow.com/questions/11916813/displaying-data-from-one-page-to-another [ ^ ]


您将被要求使用转发器的itemdatabound事件或itemCommand事件,下面给出了一个示例。



ASPX:



You will be required to use either the itemdatabound event or itemCommand event of the repeater, a sample is given below.

ASPX:

<pre lang="xml"><asp:Repeater ID="MyRepeater" runat="server" OnItemDataBound="MyRepeater_ItemDataBound">
                                <HeaderTemplate>
                                    <table border="0" cellpadding="2" cellspacing="0" width="100%" class="bo">
                                        <tr class="tBg1">
                                            <td align="Center" style="font-size: 18px">
                                                <strong>Heading1</strong>
                                            </td>
                                            <td align="Center" style="font-size: 18px">
                                                <strong>Heading2</strong>
                                            </td>
                                            <td align="Center" style="font-size: 18px">
                                                <strong>Heading3</strong>
                                            </td>
                                            <td align="Center" style="font-size: 18px">
                                                <strong>Heading4</strong>
                                            </td>
                                            <td align="Center" style="font-size: 18px">
                                                <strong>Heading5</strong>
                                            </td>
                                        </tr>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <tr id="MainRow" runat="Server">
                                        <td class="bor bob" align="left" style="font-size: 18px">
                                            <asp:Label ID="status" runat="server" Text='<%# Eval("status")%>'></asp:Label>
                                        </td>
                                        <td class="bor bob" align="center" style="font-size: 18px">
                                            <a id="lnkCount" runat="server" target="_blank">
                                                <asp:Label runat="server" ID="Labell" Text='<%# Eval("1Count")%>'></asp:Label>
                                            </a>
                                        </td>
                                        <td class="bor bob" align="center" style="font-size: 18px">
                                            <a id="lnkCount24" runat="server" target="_blank">
                                                <asp:Label runat="server" ID="Label1" Text='<%# Eval("2Count")%>'></asp:Label>
                                            </a>
                                        </td>
                                        <td class="bor bob" align="center" style="font-size: 18px">
                                            <a id="lnkCount48" runat="server" target="_blank">
                                                <asp:Label runat="server" ID="Label3" Text='<%# Eval("3Count")%>'></asp:Label>
                                            </a>
                                        </td>
                                        <td class="bor bob" align="center" style="font-size: 18px">
                                            <a id="lnkCount72" runat="server" target="_blank">
                                                <asp:Label runat="server" ID="Label2" Text='<%# Eval("4Count")%>'></asp:Label>
                                            </a>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                                <FooterTemplate>
                                    </table>
                                </FooterTemplate>
                            </asp:Repeater>







CS:






CS:

protected void rptDetailed_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
	if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
		HtmlAnchor lnkCount = (HtmlAnchor)e.Item.FindControl("lnkCount");
            HtmlAnchor lnkCount24 = (HtmlAnchor)e.Item.FindControl("lnkCount24");
            HtmlAnchor lnkCount48 = (HtmlAnchor)e.Item.FindControl("lnkCount48");
            HtmlAnchor lnkCount72 = (HtmlAnchor)e.Item.FindControl("lnkCount72");

		Label status = (Label)e.Item.FindControl("status");
	}
}







您需要先找到所需的控件来自示例中提到的事件中的转发器项。



之后,所有上述变量都可以很容易地用作常规的asp .net控件。




You need to first find the required control from the repeater item in the event as mentioned in the example.

After that all the above variables can be easily used as regular asp .net controls.


这篇关于将控件的数据从转发器传输到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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