asp.net – vb中的Datalist.试图获取datalist中行或单元格的特定
发布时间:2020-12-16 06:46:53 所属栏目:asp.Net 来源:网络整理
导读:我有一个vb web形式的datalist. 如何获取数据列表的特定行和单元格中的值? 我可以为detailview做这个,但是如何为datalist做呢? 以下是我的详细信息代码: Dim selectedCommentAns As String = DetailsView.Rows(0).Cells(1).Text 我为datalist尝试了相同的
我有一个vb web形式的datalist.
如何获取数据列表的特定行和单元格中的值? 我可以为detailview做这个,但是如何为datalist做呢? 以下是我的详细信息代码: Dim selectedCommentAns As String = DetailsView.Rows(0).Cells(1).Text 我为datalist尝试了相同的方法,但它没有选择行和单元格. 这是我的datalist的asp标记: <asp:DataList ID="DataListPhotoGallery" runat="server" CellPadding="5" CellSpacing="12" DataKeyField="PhotographerPhotoId" DataSourceID="SqlDataSourcePhotoGallery" RepeatColumns="3"> <ItemTemplate> <asp:Image ID="Image1" runat="server" BorderColor="#C7B273" BorderStyle="Groove" BorderWidth="12px" Height="200px" ImageUrl='<%# Eval("PhotographerPhotoImgPath","images/UserUploadedPhoto/{0}") %>' Width="220px" /> <br /> Photo No: <asp:Label ID="PhotographerPhotoIdLabel" runat="server" Text='<%# Eval("PhotographerPhotoId") %>' /> <br /> Photo Description: <asp:Label ID="PhotographerPhotoDescLabel" runat="server" Text='<%# Eval("PhotographerPhotoDesc") %>' /> <br /> Photo Name: <asp:Label ID="PhotographerPhotoImgNameLabel" runat="server" Text='<%# Eval("PhotographerPhotoImgName") %>' /> <br /> Photographer Name: <asp:Label ID="PhotographerIdLabel" runat="server" Text='<%# Eval("PhotographerName") %>' /> <br /> <asp:Button ID="AddCommentBtn" runat="server" CommandArgument='<%# Eval("PhotographerPhotoId") %>' Font-Bold="True" Font-Size="Medium" onclick="AddCommentBtn_Click" Text="Add Comment" /> <asp:Button ID="Button2" runat="server" CommandArgument='<%# Eval("PhotographerPhotoId") %>' Font-Bold="True" Font-Size="Medium" onclick="Button2_Click" Text="Order Photo" /> <br /> 解决方法
DataList具有名为Items的属性,而不是Rows和Cells,它允许您访问其数据绑定项的集合:
Dim itemIndex As Integer = 9 Dim label As Label = DataListPhotoGallery.Items(itemIndex).FindControl("PhotographerPhotoIdLabel") Dim text As String = label.Text 如果您知道行索引和列索引但不知道项索引,则可以像下面这样计算项索引: >如果RepeatDirection为Horizo??ntal:itemIndex = rowIndex * RepeatColumns columnIndex>如果RepeatDirection为Vertical:如果需要,请发表评论,因为它相当复杂. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- asp.net-mvc – MVC Preview 5 – 将视图呈现为字
- asp.net-mvc – Uploadify(会话和身份验证)与ASP
- asp.net-mvc – MVC发布IPagedList
- asp.net-mvc-3 – MVC Razor – 创建/编辑视图最
- ASP.NET -- WebForm -- Cookie的使用
- asp.net-mvc – ASP.NET MVC控制器的静态方法
- asp.net – HTTP错误400 – 与Topshelf的OWIN
- asp.net-mvc – UpdateModel前缀 – ASP.NET MVC
- asp.net – 正在生成无效的Webresource.axd参数
- 开发自己的Data Access Application Block[上篇]
热点阅读