Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hello everyone,

I've spent hours searching through the Internet never finding anything relevant to my problem.

I've created a GridView, and populating it with the data from the SQL table. All working perfectly. What I do not understand is how to add a combobox next to each product. All I want in it is "1,2,3,4,5", nothing else, for quantity. I really do not want to make 5 fields in my table, just to store those numbers in. Because first of all, this will add too much redundancy in my data. Plus, what if I had 50 products?!?! Is there an easy way, just to make a combobox that next to each product with 1,2,3,4,5 in it. And then, from my code, refering to the selected number, through something like .SelectedIndex. Is that possible?! I just want to see some kind of example. I don't have errors related to that.

What I've tried is, treating it like php:

 

             
<asp:TemplateField HeaderText="Qty" > 
        <EditItemTemplate> 
           <asp:DropDownList ID="DropDownQty" Runat="server" AppendDataBoundItems="true" DataSourceID="datasource"  DataTextField="key" DataValueField="data" AutoPostBack="True"> 
              <asp:ListItem Value="1">1</asp:ListItem> 
              <asp:ListItem Value="2">2</asp:ListItem> 
              <asp:ListItem Value="3">3</asp:ListItem> 
              <asp:ListItem Value="4">4</asp:ListItem>
              <asp:ListItem Value="5">5</asp:ListItem>  
           </asp:DropDownList>
        </EditItemTemplate> 

        </asp:TemplateField>

 

But this doesn't display anything except an empty column with "Qty" name on it.

 

Also in my code, when I go myGridView.Columns.Add( - its not giving me a combobox. A combobox also doesn't get displayed in the Smart Tag. When I try to add it through html it's not coming up with an error, but it's not displaying anything at the same time. When I try Dim combo As New DataGridViewComboBoxColumn - it says undefined

 

Thanks in advance.

Widunder.

Edited by Widunder

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...