Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i get the textbox text value in gridview?

ASP.NET
<asp:gridview ID="Gridview1" runat="server" ShowFooter="True" AutoGenerateColumns="False" HeaderStyle-BorderStyle="None">
                        <Columns>
                        <asp:BoundField DataField="RowNumber" HeaderText="" ItemStyle-Width="5px" HeaderStyle-Width="5px">
                            <ControlStyle Height="5px" />
                            <FooterStyle Width="5px" />
                        <HeaderStyle Width="5px"></HeaderStyle>

                        <ItemStyle Width="5px"></ItemStyle>
                                    </asp:BoundField>
                                <asp:TemplateField HeaderText="Miktar">
                                    <ItemTemplate>
                                        <asp:TextBox ID="txt1" runat="server"></asp:TextBox>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Malzeme">
                                    <ItemTemplate>
                                        <asp:TextBox ID="txt2" runat="server"></asp:TextBox>
                                    </ItemTemplate> 
                                     <FooterStyle HorizontalAlign="Right" />
                                    <FooterTemplate>
                                     <asp:Button ID="ButtonAdd" runat="server" Text="Yeni Satır Ekle" OnClick="ButtonAdd_Click" CausesValidation="false" />
                                    </FooterTemplate>
                                </asp:TemplateField>
                                </Columns>

                        <HeaderStyle BorderStyle="None"></HeaderStyle>
                            
                </asp:gridview>


What I have tried:

creating virtual text box but its coming null
Posted
Updated 8-Jun-16 23:08pm

1 solution

 
Share this answer
 
Comments
Member 10525430 9-Jun-16 5:34am    
textbox.text =null or empty
Kats2512 9-Jun-16 9:03am    
what is this supposed to mean?

You should find your textbox first by writing some code like below:
foreach (GridViewRow gvr in GridView1.Rows)
{
TextBox txt1 = (TextBox)gvr.FindControl("txt1");
string txt1Val = txt1.text; //Set the variable to the value you get from the textbox then do what you need to do with it.
}

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