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
Sumit Kesarwani
20-Nov-2014I would add a HiddenField in the TemplateField to hold the CartID, I will use the CartID in the code. My Markup should look like:
In the code, in GridView's RowDataBound I am finding the DropDownList and HiddenField, running a Sql Query to bring my expected data, and binding them to my DropdownList: