我如何在Datalist中的所有值与asp.net/vb.net一个按钮
-
21-09-2019 - |
题
我有问题得到在数据列表中的所有值
这里的问题是:
我有数据列表被动态地从在数据库表中填入,aspx页面是大量订单页面所以有在数据列表许多项目,我希望用户能够一次在<强> 到SELCT多个订单STRONG>模式并选择在buuton 这就是所谓退房,现在的问题是我怎么循环throuhg所有的复选框和文本框和获得的价值。任何想法编码将有助于termendously因为我没有的代码,但在所有。
这是我的aspx页面:
<asp:DataList ID="DataList1" runat="server" BackColor="White" BorderColor="#CCCCCC"
BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyField="Id"
DataSourceID="SqlDataSource1" GridLines="Both">
<FooterStyle BackColor="White" ForeColor="#000066" />
<ItemStyle ForeColor="#000066" />
<SelectedItemStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<FooterTemplate>
<asp:Button ID="btnNext" runat="server" Text="CheckOut"
onclick="btnNext_Click" />
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
<br />
<asp:Image ID="Image1" ImageUrl='<%# Eval("PictureUrlMedium") %>' runat="server" />
<br />
<asp:Label ID="DescriptionLabel" runat="server"
Text='<%# Eval("Description") %>' />
<br />
<br />
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell><asp:CheckBox ID="chkSmall" runat="server" Enabled="true" Width="20px"/>
小,点击
中点击
大结果
XLARGE
2XLarge
3XLarge
4XLarge
5XLarge
,点击
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:LocalSqlServer %>"
SelectCommand="SELECT [Id], [Title], [Description], [Price], [CategoryId], [PictureUrlSmall], [PictureUrlMedium], [PictureUrlLarge], [Deleted] FROM [Product]"></asp:SqlDataSource>
解决方案
您可以通过在点击事件DataList控件项目循环实现这一目标
foreach(DataListItem item in YourDataList.Items){
CheckBox chkSmall = (CheckBox)item.FindControl("chkSmall");
chkSmall.Checked gives you the value
}
其他提示
在回发,通过数据列表中的项目,并循环使用得到的FindControl的复选框的状态。您可能要添加的东西到DataList的项目,以确定相应的复选框实际的实体。