Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 628577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:39:06+00:00 2026-05-13T19:39:06+00:00

I have a GridView on an ASP.NET page with a TemplateField column that has

  • 0

I have a GridView on an ASP.NET page with a TemplateField column that has a TextBox in the ItemTemplate. I then have a command field which is supposed to pull the text from this TextBox and use it in a SqlCommand running a stored procedure.

Here is my C# code:

int index = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = this.gvwSNConfirm.Rows[index];
TableCell intID = selectedRow.Cells[1];
int reqID = int.Parse(intID.Text);
// Get the SN from the text box on the selected row
TableCell snCell = selectedRow.Cells[0];
TextBox tbox = (TextBox)staffNum.FindControl("txtSN");
string stSN = tbox.Text.ToString();

When I add a break point to see the values for intID and tbox.Text I get the right ID but the Text for tbox is “”.

The mark-up for the two columns I am referencing is

<asp:TemplateField HeaderText="SN">
  <ItemTemplate>
    <asp:TextBox ID="txtSN" runat="server" MaxLength="20" Width="100px" />
  </ItemTemplate>
  <HeaderStyle BackColor="#171695" Font-Names="Arial" Font-Size="Small" ForeColor="White" Wrap="true" />
</asp:TemplateField>
<asp:BoundField DataField="Request" HeaderText="Request" ReadOnly="true" SortExpression="Request" />

Can anyone provide any help why I cant get the text from the text box? It worked the first time round but subsequently all tbox text values have been “”.

Many Thanks

Andy

NEW CODE (05/03/2010):

protected void gvwSecond_RowCommand(object sender, GridViewCommandEventArgs e)
{
  if ((e.CommandName == "Confirm") || (e.CommandName == "Decline"))
  {
    int index = Convert.ToInt32(e.CommandArgument);
    GridViewRow row = gvwSecond.Rows[index];

    int secondID = int.Parse(row.Cells[1].Text);
    TextBox txtsn = ((TextBox)row.FindControl("txtSecSN"));
    string sn = txtsn.Text;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:39:07+00:00Added an answer on May 13, 2026 at 7:39 pm

    What event is this code in? You should e.Item.FindControl. If you are getting the right control for sure, but Text is empty, that means it’s either not getting posted back, or it’s being cleared somewhere else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a devexpress gridview within my asp.net page which has a filter row.
I have a GridView control in an Asp.net application, that has a <asp:buttonField> of
I have a GridView control on my ASP.NET page that binds to result set
I have a GridView on an ASP.NET page that I'm trying to bind to
I have asp.net's .aspx page. that have GridView let say GridViewParent and Each row
I have an ASP.NET page that has dynamically created LinkButton elements. Please note that
I have a gridview in ASP.net 2.0 that has a small peace of javascript
On an ASP.NET page, I have a GridView populated with the results of a
I have an ASP.NET page with a gridview control on it with a CommandButton
I have an Asp.Net page containing one GridView and a couple of images (google

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.