Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Get Text of Gridview TextBox on button click
Pankaj Singh
Apr 13 2012 12:31 PM
3.7k
Reply
Hi,
I want to get the text of TextBox of gridview on Button click.
I am using following code:
source code-
<asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="False"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="3"
style="font-size: small; font-family: Arial">
<RowStyle ForeColor="#000066" />
<Columns>
<asp:BoundField DataField="Data_type" HeaderText="type" />
<asp:BoundField DataField="column_name" HeaderText="Column" />
<asp:TemplateField HeaderText="Value">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
cs file code:
protected void btninsert_Click(object sender, EventArgs e)
{
for (int i = 0; i <= Gridview1.Rows.Count - 1; i++)
{
TextBox txt1 = (TextBox)Gridview1.Rows[i].Cells[2].FindControl("TextBox1");
string str=txt1.Text;
}
but in str I am getting only space "". plz help me
Thanks in advance
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Unable to evaluate expression because the code is optimized
call garbage collector