Solved

ASP.NET GRIDVIEW - ADDING COMBO BOX

Posted on 2009-07-02
6
2,109 Views
Last Modified: 2013-11-25
How can I add a combo box column to an asp.net gridview control using vb.net?  I have the code that adds a column that's bound but how do I make it combo boxes?


Try '...add column

            grdOSS0.AutoGenerateColumns = False

            Dim Field As New BoundField

            Field.DataField = "part"

            Field.HeaderText = "Part"

            Dim Col As DataControlField = Field

            grdOSS0.Columns.Add(Col)

            grdOSS0.DataBind()

        Catch ex As Exception
 

        End Try

Open in new window

0
Comment
Question by:jseg
  • 4
  • 2
6 Comments
 
LVL 9

Expert Comment

by:AsishRaj
ID: 24767468

<asp:TemplateField SortExpression="State" HeaderText="State" >

         <EditItemTemplate>

            <asp:DropDownList DataTextField="State" DataValueField="State" ID="DropDownList2" Runat="server" SelectedValue='<%# Bind("State") %>' >

               <asp:ListItem>CA</asp:ListItem>

               <asp:ListItem>VT</asp:ListItem>

               <asp:ListItem>UT</asp:ListItem>

               <asp:ListItem>MD</asp:ListItem>

            </asp:DropDownList>

         </EditItemTemplate>

         <ItemTemplate >

            <asp:Label Runat="server" Text='<%# Bind("State") %>' ID="Label1"></asp:Label>

         </ItemTemplate>

</asp:TemplateField>

Open in new window

0
 
LVL 9

Expert Comment

by:AsishRaj
ID: 24767484
0
 
LVL 9

Accepted Solution

by:
AsishRaj earned 500 total points
ID: 24781331
Hi jseg

did you manage to get it working. let us know if you need additional help with it


AR
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Closing Comment

by:jseg
ID: 31599362
Yes, thanks for the help!
0
 

Author Comment

by:jseg
ID: 24788765
I selected to code it programmatically, thanks!
0
 
LVL 9

Expert Comment

by:AsishRaj
ID: 24788865
Glad that i was able to help you.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now