datalist
2014-09-04 56 views 1 likes 
1

获得项目我在ASCX文件中的以下内容:如何从DataList控件

<asp:DataList ID="dtlTabs" runat="server" RepeatDirection="Horizontal" EnableViewState="False" CellPadding="0"> 
    <ItemTemplate> 
     <asp:HyperLink ID="hlTab" NavigateUrl='<%# Eval("Url")%>' Tag='<%# Eval("Key") %>' Text='<%# Eval("Title") %>' runat="server"></asp:HyperLink> 
    </ItemTemplate> 
</asp:DataList> 

而不是通过它迭代作为一个DataList,我只能打印第3项的标题?我不确定如何从dtlTabs中选择一个项目并打印出来。

回答

0

明白了:

Dim dt As Data.DataSet = DirectCast(dtlTabs.DataSource, Data.DataSet) ' Cast the datasource back into a dataset 
Dim dr As Data.DataRow = dt.Tables(0).Rows(4) ' Take the fourth row from the first table 

Response.Write(dr("Title")) ' Output the text 
相关问题