Click here to Skip to main content
15,896,489 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to add the textbox for search option in the gridview ? Is that possible if yes then what should I do to do so.
Posted

On the right top of gridview click add column and add an Itemtemplate. Then click edit templates and add a textbox by using toolbox.

Searching is a codebehind stuff. Create a method under the related class and get the parameter that you have send via gridview's textbox.

Sorry for my English. It is not my mother tongue.

Emre.
 
Share this answer
 
Comments
Codes DeCodes 2-Oct-13 5:07am    
I too faced a similar problem as posted by Mr. Saroj.. your solution created a column.. I want a row to be created instead of column.. Can you plz help..
FoxRoot 2-Oct-13 5:10am    
Could you draw your wish on paint :) I didin't understand. A row consists of textboxes? or just one textbox.
Codes DeCodes 2-Oct-13 5:18am    
http://www.codeproject.com/Answers/661570/add-textbox-in-row-of-grid-view#answer1

here is the design I want that i had posted earlier.. and thanks in advance.
 
Share this answer
 
you can use something like this.

XML
<ItemTemplate>
    <asp:TextBox ID="TxtFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
</ItemTemplate>


initialy you keep the textbox disable and than
onclick of the row event you can enable the textbox so that user can insert value in that.
 
Share this answer
 
<asp:GridView ID="OrderGridView" runat="server" AllowPaging="True" 
                                    BorderStyle="None" CellPadding="3" DataKeyNames="Article" 
                                    Font-Size="Small" HorizontalAlign="Left" 
                                    OnPageIndexChanging="OrderGridView_PageIndexChanging" PageSize="20" 
                                    TabIndex="15" Width="866px" BackColor="White" BorderColor="#CCCCCC" 
                                    BorderWidth="1px">
                                    <FooterStyle BackColor="White" ForeColor="#336699" />
                                    <HeaderStyle BackColor="#336699" Font-Bold="True" ForeColor="White" />
                                    <PagerSettings FirstPageText="First" LastPageText="Last" />
                                    <PagerStyle BackColor="White" ForeColor="#336699" HorizontalAlign="Left" />
                                    <RowStyle ForeColor="#336699" Font-Size="Small" />
                                    <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                                    <SortedAscendingCellStyle BackColor="#F1F1F1" />
                                    <SortedAscendingHeaderStyle BackColor="#007DBB" />
                                    <SortedDescendingCellStyle BackColor="#CAC9C9" />
                                    <SortedDescendingHeaderStyle BackColor="#00547E" />
                                    <Columns>
                                        <asp:TemplateField HeaderText="Delete" ItemStyle-HorizontalAlign="Center" >
                                        <ItemTemplate>
                                            <asp:CheckBox ID="CheckBox1" runat="server" />
                                        </ItemTemplate>
                                        </asp:TemplateField>
                                         <asp:TemplateField HeaderText="Update Cartons Quant." ItemStyle-HorizontalAlign="Center" ItemStyle-Width="40">
                                        <ItemTemplate>
                                            <asp:TextBox ID="TextBox" runat="server" Width="90" />
                                        </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>


This is a sample of how to insert a textbox in gridview. Then you will need to right some code behinde for search thing.
I hope i could help..
 
Share this answer
 
v4
Comments
Codes DeCodes 2-Oct-13 7:21am    
Dianaa this code reutrns header at first and then textbox throughout the column.. But i want textbox only at second column and then the records from database from third column..
Diana Tsax 2-Oct-13 7:28am    
sorry i just remove some columns and i missed it.. here is my full code, you can delete whatever you don't need. In my code the first two columns are checkbox and textbox and the others are from db.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900