How to embed drop down with Grid view in

Posted on 2011-10-11
Last Modified: 2012-05-12
I have a gridview containing data pouplated from table having 5 columns.
I want to add dropdown in 6th column, and textbox in 7th column.
<asp:Gridview id="g1" runat="server"/>
Question by:searchsanjaysharma
    LVL 38

    Accepted Solution


    <asp:GridView ID="g1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1">
                    <asp:BoundField DataField="id" HeaderText="Column 1" />
                    <asp:BoundField DataField="randomData" HeaderText="Column 2" />
                    <asp:BoundField DataField="sort" HeaderText="Column 3" />
                    <asp:BoundField DataField="sort" HeaderText="Column 4" />
                    <asp:BoundField DataField="sort" HeaderText="Column 5" />
                    <asp:TemplateField HeaderText="Drop Down List">                            
                            <asp:DropDownList ID="ddlTest" runat="server">
                                <asp:ListItem Text="Item 1" Value="item_1"></asp:ListItem>
                                <asp:ListItem Text="Item 2" Value="item_2"></asp:ListItem>
                                <asp:ListItem Text="Item 3" Value="item_3"></asp:ListItem>
                                <asp:ListItem Text="Item 4" Value="item_4"></asp:ListItem>
                    <asp:TemplateField HeaderText="Text Box Field">
                            <asp:TextBox ID="txtTest" runat="server" Text="text"></asp:TextBox>                                

    Open in new window


    Author Closing Comment


    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    732 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

    21 Experts available now in Live!

    Get 1:1 Help Now