如何从所选中继器中选择和显示数据 [英] How Do I Select and Show Data from Selected Repeater
问题描述
所以我的情况是这样的,我需要做的是显示复选框上选中的行数据,
我有一个初始解决方案,我所做的是将表数据ID作为工具提示分配给复选框,并将显示,
txtShow.Text = txtShow.Text + myCheckbox.Tooltip。 ToString
这样做有好处,因为我绝对不希望将数据ID显示为复选框的工具提示。我是一名初级程序员,基本上都是按照自己的方式工作。感谢所有未来的帮助。
基本上我有以下代码,
IN ASPX
So my situation is like this, what I need to happen is to show the row data that are checked on the checkbox,
I have an initial solution, what I did is assign the table data ID as a tooltip to the checkbox, and will be displayed with,
txtShow.Text = txtShow.Text + myCheckbox.Tooltip.ToString
Is there a better of doing this, cause I definitely don't want to show the data ID as a tooltip for the checkbox. I'm a junior programmer and basically trying to work my way. Thanks for all the future help.
Basically I have the following codes,
IN ASPX
<table>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="cbRows" runat="server" ToolTip='<%# Eval("ID") %>' />
</td>
<td>
<%# Eval("ProductID")%>
</td>
<td>
<%# Eval("ProductName")%>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
In my Codebehind VB,
Protected Sub bCheck_Click(ByVal sender As Object, ByVal e As EventArgs) Handles bCheck.Click
txtShow.Text = ""
Dim i As Integer = 0
Dim item As RepeaterItem
For Each item In Repeater1.Items
Dim myCheckBox As CheckBox = item.FindControl("cbRows")
If Not myCheckBox Is Nothing And myCheckBox.Checked Then
' I put my initial code here, which uses the tooltip.
End If
i = i + 1
Next
End Sub
推荐答案
这篇关于如何从所选中继器中选择和显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!