forum

Home / DeveloperSection / Forums / how to get values in dropdownlist bounded within a gridview?

how to get values in dropdownlist bounded within a gridview?

Anonymous User 2649 20-Nov-2014

Inside gridview a dropdownlist is there 

<asp:TemplateField HeaderText="Quantity">
    <ItemTemplate>
        <asp:DropDownList ID="quantity" runat="server" DataValueField="ItemID" DataTextField="Quantity">
        </asp:DropDownList>
    </ItemTemplate>
</asp:TemplateField>

for each itemid there is some numeric value in Quantity field of Database Table i want that this dropdown must contain the values from 1 to quantity.DataTextField for all the items present in the cart 

the procedure by which gridview is bound is 

create proc [dbo].[prcItemsinCart](@CartID int)
as
    select distinct ct.Price,ct.Quantity,ct.ItemID,
           ct.CartID,ct.ProductID,p.ProductName,
           isnull((  select top 1 convert(varchar,PhotoID,10) + '.' + ExtName
                 from ProductPhoto
                 where ProductID = ct.ProductID ),'NoImage.jpg'
           ) as Product,
           ( Select Price*Quantity
             from CartItems
             where CartID=ct.CartID and ProductID=ct.ProductID
           ) as SubTotal
    from CartItems as ct
    inner join ProductInfo as p on ct.ProductID=p.ProductID
    inner join ProductPhoto as pp on ct.ProductID=pp.ProductID
    where ct.CartID=@CartID

Updated on 20-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By