How to embed drop down with Grid view in asp.net

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"/>
searchsanjaysharmaAsked:
Who is Participating?
 
Tom BeckConnect With a Mentor Commented:

<asp:GridView ID="g1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1">
            <Columns>
                <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">                            
                    <ItemTemplate>
                        <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:DropDownList>                                
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Text Box Field">
                    <ItemTemplate>
                        <asp:TextBox ID="txtTest" runat="server" Text="text"></asp:TextBox>                                
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

Open in new window

0
 
searchsanjaysharmaAuthor Commented:
tHANX
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.