Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 12th, 2009, 03:28 AM
Authorized User
Join Date: Jan 2009
Posts: 23
Thanks: 8
Thanked 0 Times in 0 Posts
Default Retrieving value from textbox in a Gridview

Hey pple. i am facing a problem now whereby i could not retrieve value from a textbox in a gridview. I want it to be store in a database in the future. Now i need to identify the existence of a textbox first, before i could actually store the value in the textbox.

The problem that i am facing now is actually because, my textbox is declare inside a gridview, hence it is not detectable/declare in the aspx form.

Textbox name : Notestxtbox

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
publicpartialclass_Default : System.Web.UI.Page
protectedvoid Page_Load(object sender, EventArgs e)
GridViewRow row = this.GridView1.Rows[this.GridView1.EditIndex];
TextBox LastName = (TextBox)row.Cells[2].FindControl("Notestxtbox");
UpdateIDlbl.Visible = false;
Emaillbl.Visible = false;
Textinput.Visible = false;
string strConString = ConfigurationManager.ConnectionStrings["SocialSystemConnectionString"].ConnectionString;
SqlConnection con = newSqlConnection(strConString);
SqlCommand cmd = newSqlCommand("SELECT UpdateID FROM [Update]", con);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
UpdateIDlbl.Text = reader["UpdateID"].ToString();
GridView1.Visible = false;


<asp:TextBoxID="TextBox1"runat="server"Text='<%# Bind("FullName") %>'></asp:TextBox>
<ahref=""><asp:LabelID="Label1"runat="server"Text='<%# Bind("FullName") %>'></asp:Label></a> wrote a note.<br/><br/>
<asp:LabelID="Label2"runat="server"Text='<%# Bind("TextInput") %>'></asp:Label><br/><br/><asp:TextBoxID="TextBox2"runat="server"Height="44px"Width="292px"Visible="false"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp<asp:ButtonID="NoteComment"runat="server"OnClick="NoteComment_Click"Text="Comment"/>&nbsp;<br/><br/>

Last edited by julius; March 12th, 2009 at 03:31 AM..
Old March 12th, 2009, 08:12 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

Hello there..

Besides there is a forum specific for asp.net, why are you looking for the box in the page load??? and also, why look for it if you are not doing anything with it???


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
================================================== =========
I know that CVS was evil, and now i got the
================================================== =========

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get GridView Cell Value Based on GridView Column stublair C# 2008 aka C# 3.0 0 September 4th, 2008 08:30 AM
GridView Textbox Limno .NET Framework 1.x 0 May 28th, 2008 02:35 PM
Dynamic textbox generation into gridview dharmeshtandel ASP.NET 2.0 Basics 3 December 24th, 2007 02:14 AM
TextBox inside GridView michurin ASP.NET 2.0 Basics 2 January 13th, 2007 12:51 PM
Masked TextBox & formatting TextBox melvik C# 1 September 22nd, 2003 11:01 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.