中继器控件中的复选框单击事件 [英] checkbox click event in repeater control
问题描述
我已经 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 [
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 andButton2
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 [此处 [
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>
这篇关于中继器控件中的复选框单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!