中继器控件中的复选框单击事件

编程入门 行业动态 更新时间:2024-10-19 05:20:16
本文介绍了中继器控件中的复选框单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经 bind 绑定了 SqlServer 2005 的 Repeater 控件中的某些数据;现在的问题是,在 Repeater 控件中,我有 CheckBox ,无论从转发器中选择的任何项目都应转换为 PDF 文件,详细信息东西在 Repeater 中,我随机选择项目,当我单击 PDF 按钮时,应该将其转换为 PDF ;无论在aspx页面中应用了什么Alignment,都应该将相同的Alignment应用于 PDF 请帮帮我. 在此先谢谢您.

I have binded bound some data in Repeater control from SqlServer 2005; now the issue is, in Repeater control I have CheckBox ,whatever items which are selected from the repeater should be converted into PDF file, the detail thing is in Repeater I randomly select items, and when I click the PDF button it should be converted into PDF; whatever Alignment applied in aspx page, the same Alignment should be applied to PDF too Please help me. Thanks in advance.

推荐答案

要确定是否选中了复选框,您需要首先使用FindControl [ ^ ]方法. 假设这是您的转发器,而Button2是您的导出到PDF按钮: For determining whether the Checkboxes are checked, you need to look for the control first by using FindControl[^] method of the repeater item. Suppose this is your repeater and Button2 is your export to PDF button: <asp:Button ID="Button2" runat="server" onclick="Button2_Click" /><br /> <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand"> <ItemTemplate> <asp:CheckBox ID="Checkbox1" runat="server" /> <asp:Label ID="Label2" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Name")%>' /> <br /> </ItemTemplate> </asp:Repeater>

您可以通过实现类似于以下内容的方法来实现您的目标.

You can accomplish your goal by implementing something similar to the one below.

protected void Button2_Click(object sender, EventArgs e) { foreach (RepeaterItem item in Repeater1.Items) { if (((CheckBox)item.FindControl("Checkbox1")).Checked) { //Do something } } }

现在可以过滤选中的项目了,您可以使用一些第三方API,例如 ITextSharp [ ^ ]即可将数据导出到PDF. 此处 [ ^ ]是关于API入门的好教程.

Now that can filter checked items, you can use some third party API like ITextSharp[^] to export data to PDF. Here[^] is a good tutorial for starters about the API.

< b> jitendra Negi</b>你好< a href ="></a> <b>jitendra Negi </b> hello <a href=""></a>

更多推荐

中继器控件中的复选框单击事件

本文发布于:2023-11-25 01:57:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627845.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   单击   复选框   事件   中继器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!