如何在datalist中找到项目的索引 [英] how to find index of item's in datalist

查看:52
本文介绍了如何在datalist中找到项目的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据列表我想找出其中book_id == 73

的单元格的索引值,并希望在dt单元格中显示一些标签文本

this是我的datalist

 <   asp:DataList     ID   =  dl_cartitems     runat   =  server    

onitemcommand = dl_cartitems_ItemCommand >
< ItemTemplate >
< <温泉n class =code-leadattribute> tr bgcolor = #FFFFFF class = product-detail >
< td width = < span class =code-keyword> 14% valign = top > < img src =' <% book_image / + Eval( 图像)%>' width = 128px 样式 = margin-top:10px; margin-right:10px; margin-left:10px; margin-bottom:10px / > < / td >
< td width = 43% valign = top style = padding-removed10px > Khalid Hosseini的风筝跑者< br / > < asp:Label ID = discount_message runat = 服务器 > < / asp:标签 > < / td >
< td width = 6% align = < span class =code-keyword> center
valign = top style = padding-removed10px > < a href = > 编辑< / a > < / td >
< td width = 10% align = center valign < span class =code-keyword> =
top 样式 = padding-removed10px > $ < asp:Label ID = lbl_parprice runat = server 正文 =' <% #Eval( 价格)%>' > < / asp:Label > < / td >
< td width = 10% align = center valign = top style = padding-removed10px >
< asp:DropDownList ID = ddl_quantity runat = server 宽度 = 60px OnSelectedIndexChanged = ddl_quantity_selectedindexchanged AutoPostBack = < span class =code-keyword> true >
< span class =code-keyword>< asp:ListItem > 1 < span class =code-keyword>< / asp:ListItem >
< asp:ListItem > 2 < / asp:ListItem >
< / asp:DropDownList > < / td >
< td width = 12% align = center valign = top style = padding-removed10px > $ < asp:Label < span class =code-attribute> ID = lbl_subtoprice runat = server 文字 =' <% #Eval( 价格)%>' > < / asp:Label > < / td >
< td width = 5% align = center valign = top < span class =code-attribute> style = padding-removed10px > < asp:ImageButton ID = imgbtn_del ImageUrl = < span class =code-keyword>〜/ images / del.jpg runat = server CommandName = 删除 CommandArgument =' <% #Eval( id) %>' > < / asp:ImageButton > < / td >
< / tr >
< / ItemTemplate >
< span class =code-keyword>< / asp:DataList >



这是我的datalist现在我想找到book_id为73的单元格,并希望在该单元格的标签中显示一些文本

以下代码< pre lang =HTML> < asp:标签 ID = discount_message runat = server > < / asp:Label >



感谢

解决方案

< asp:标签 ID = lbl_parprice runat = 服务器 文字 =' <% #Eval( 价格)%>' > < / asp:标签 > < / td >
< td 宽度 = 10% align = center < span class =code-attribute> valign = top style = padding-removed10px >
< asp:DropDownList ID = ddl_quantity runat = server < span class =code-attribute> 宽度 = 60px OnSelectedIndexChanged = ddl_quantity_selectedind交换 AutoPostBack = true >
< asp:ListItem > 1 < / asp:ListItem >
< asp:ListItem > 2 < / asp:ListItem > ;
< / asp:DropDownList > < / td >
< td 宽度 = 12% align = center valign = top style = padding-removed10px >


< blockquote> < asp:Label ID = lbl_subtoprice runat = server 文字 < span class =code-keyword> =' <% #Eval( 价格)%>' < span class =code-keyword>> < / asp:Label < span class =code-keyword>> < / td >
< td width = 5% align < span class =code-keyword> = center valign = top 样式 = padding-removed10px > < asp:ImageButton ID = imgbtn_del ImageUrl = 〜/ images / del.jpg runat = 服务器 CommandName = 删除 CommandArgument =' <% #Eval( id)%> ' > < / asp:ImageButton > < / td >
< / tr >
< / ItemTemplate >
< span class =code-keyword>< / asp:DataList >



这是我的datalist现在我想找到book_id为73的单元格,并希望在该单元格的标签中显示一些文本

以下代码< pre lang =HTML> < asp:标签 ID = discount_message runat = server > < / asp:Label >



谢谢


尝试使用数据行绑定事件。绑定每一行后触发,然后您可以使用变量来存储索引号。


i have a datalist i want to find out index value of the cell in which book_id==73
and want to show some labels text in dt cell
this is my datalist

<asp:DataList ID="dl_cartitems" runat="server" 

                        onitemcommand="dl_cartitems_ItemCommand">
                  <ItemTemplate>
                  <tr bgcolor="#FFFFFF" class=" product-detail" >
                    <td width="14%" valign="top"> <img src='<%#"book_image/"+ Eval("Image") %>' width="128px" style="margin-top:10px;margin-right:10px;margin-left:10px;margin-bottom:10px" /></td>
                    <td width="43%"  valign="top" style="padding-removed10px">The Kite Runner by Khalid Hosseini <br /> <asp:Label ID="discount_message" runat="server"></asp:Label> </td>
                    <td  width="6%" align="center" valign="top" style="padding-removed10px"><a href="#">Edit</a></td>
                    <td   width="10%" align="center" valign="top" style="padding-removed10px"> $<asp:Label ID="lbl_parprice" runat="server" Text='<%#Eval("Price") %>'></asp:Label></td>
                    <td width="10%" align="center" valign="top" style="padding-removed10px">
                     <asp:DropDownList ID="ddl_quantity" runat="server" Width="60px" OnSelectedIndexChanged="ddl_quantity_selectedindexchanged" AutoPostBack="true" >
                    <asp:ListItem> 1 </asp:ListItem>
                    <asp:ListItem> 2 </asp:ListItem>
                    </asp:DropDownList> </td>
                    <td width="12%" align="center" valign="top" style="padding-removed10px">$<asp:Label ID="lbl_subtoprice" runat="server" Text='<%#Eval("Price") %>' ></asp:Label> </td>
                    <td width="5%" align="center" valign="top" style="padding-removed10px" ><asp:ImageButton ID="imgbtn_del"  ImageUrl="~/images/del.jpg" runat="server" CommandName="Delete" CommandArgument='<%#Eval("id") %>' ></asp:ImageButton></td>
                  </tr>
                  </ItemTemplate>
                  </asp:DataList>


this is my datalist now i want to find cell in which book_id is 73 and want to show some text in that cell's label
below code

<asp:Label ID="discount_message" runat="server"></asp:Label>


thanks

解决方案

<asp:Label ID="lbl_parprice" runat="server" Text='<%#Eval("Price") %>'></asp:Label></td> <td width="10%" align="center" valign="top" style="padding-removed10px"> <asp:DropDownList ID="ddl_quantity" runat="server" Width="60px" OnSelectedIndexChanged="ddl_quantity_selectedindexchanged" AutoPostBack="true" > <asp:ListItem> 1 </asp:ListItem> <asp:ListItem> 2 </asp:ListItem> </asp:DropDownList> </td> <td width="12%" align="center" valign="top" style="padding-removed10px">


<asp:Label ID="lbl_subtoprice" runat="server" Text='<%#Eval("Price") %>' ></asp:Label> </td> <td width="5%" align="center" valign="top" style="padding-removed10px" ><asp:ImageButton ID="imgbtn_del" ImageUrl="~/images/del.jpg" runat="server" CommandName="Delete" CommandArgument='<%#Eval("id") %>' ></asp:ImageButton></td> </tr> </ItemTemplate> </asp:DataList>


this is my datalist now i want to find cell in which book_id is 73 and want to show some text in that cell's label
below code

<asp:Label ID="discount_message" runat="server"></asp:Label>


thanks


try using data row bound event. It is fired after each row is bound and then you can use a variable to store index number.


这篇关于如何在datalist中找到项目的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆