如何为listview中的输入文本字段分配唯一ID

时间:2015-04-29 13:42:07

标签: asp.net listview textbox

我需要为listview中的输入文本字段分配唯一ID。这是我的代码......

<asp:ListView ID="viewProductByCategoryListView" runat="server" GroupItemCount="4"
    GroupPlaceholderID="groupPlaceHolder1" ItemPlaceholderID="itemPlaceHolder1"
    ClientIDMode="Predictable" 
    ClientIDRowSuffix="ID">
    <LayoutTemplate>
        <table>
            <asp:PlaceHolder runat="server" ID="groupPlaceHolder1"></asp:PlaceHolder>
        </table>
    </LayoutTemplate>
    <GroupTemplate>
        <tr>
            <asp:PlaceHolder runat="server" ID="itemPlaceHolder1"></asp:PlaceHolder>
        </tr>
    </GroupTemplate>
    <ItemTemplate>
        <td>
            <table cellpadding="2" cellspacing="0" style="width: 200px; height: 100px;">
                <tr>
                    <td>
                        <!--image and tooltip-->
                        <div class="uiv2-list-box-img-block">
                            <a href="../ViewProductDetails.aspx?productId='<%# Eval("ID") %>'" title='<%# Eval("Product_description") %>'>
                                <%-- <img title="Fresho Onion - Medium 1 kg approx. 10 to 12 nos" 
                                    alt="Fresho Onion - Medium 1 kg approx. 10 to 12 nos" 
                                    src="~/Picture.ashx?pic='<%# Eval("ProductImage") %>' " />--%>
                                <asp:Image runat="server" ImageUrl='<%# GetImage(Eval("ProductImage")) %>' Height="150px"
                                    Width="150px" />
                            </a>
                        </div>
                        <div>
                            <span class="name" style="display: inline; text-overflow: ellipsis; overflow: hidden;">
                                <%# Eval("ProductName") %></span>
                        </div>
                        <div class="uiv2-list-box-drop-rate-block">
                            <!--to display the unit price-->
                            <div class="ListBox_Rate_count">
                                <div class="uiv2-rate-count-avial">
                                    <span class="WebRupee">Rs.</span> <span>
                                        <%# Eval("UnitPrice") %>
                                    </span>
                                </div>
                            </div>
                            <div class="uiv2-list-rate-block">
                                <div class="uiv2-add-to-basket">
                                    <!--to display quantity-->
                                    <div class="uiv2-rate-count-btn">
                                        <span class="uiv2-qty-label">Qty</span>
                                        **<input value="1" type="text" maxlength="2" id="ProductIDTextbox"/>**
                                    </div>
                                    <asp:Button OnClientClick='<%# String.Format("return UpdateCart({0},this)", Eval("ID")) %>'
                                        runat="server" Text="ADD" />
                                </div>
                            </div>
                        </div>
                    </td>
                    <td style="border-left: 1px solid black; padding: 5px">
                    </td>
                </tr>
                <tr>
                    <td>
                        <hr runat="server" />
                    </td>
                </tr>
            </table>
        </td>
    </ItemTemplate>
</asp:ListView>

我在上面的代码中有**标记输入字段,我想为其分配唯一ID。任何人都可以告诉我这里有什么问题。

1 个答案:

答案 0 :(得分:0)

经过大量的点击和试用......我找到了解决方案....我们不能在listview或任何asp.net服务器端控件中使用具有唯一id功能的纯HTML控件。

相关问题