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 9102991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:31:18+00:00 2026-06-17T01:31:18+00:00

i have gridview control and textbox + button control in page aspx. i want

  • 0

i have gridview control and textbox + button control in page aspx.

i want pass textbox value to gridview by click button.

<asp:GridView ID="gvName" runat="server" ViewStateMode="Enabled">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblName" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

and use this code:

protected void btnAddName_Click(object sender, ImageClickEventArgs e)
    {
      foreach (GridViewRow row in gvName.Rows)
        {
            if ((Label)row.FindControl("lblName") is Label)
            {
                ((Label)row.FindControl("lblName")).Text = txtName.Text;
            }
        }
     }

but its no ok. 🙁 please help me.

  • 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-06-17T01:31:19+00:00Added an answer on June 17, 2026 at 1:31 am

    If grid row has label with id lblName then you will get it from row and you do not need to check it again.

    foreach (GridViewRow row in gvName.Rows)
    {
        Label lblName = (Label)row.FindControl("lblName");         
        lblName.Text = txtName.Text;            
    }
    

    Note: If you do not have rows already in thr gridview then you wont be able get the value in label. You need to ensure their are row(s) in grid.

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

Sidebar

Related Questions

I have an ASP.NET page where I am showing products in a Gridview control.
I have a gridview control and I want to input a value to a
I have a GridView with a bunch of DynamicFields like so; <asp:GridView ID=GridView1 runat=server
I have a button with an onclick event <asp:Button ID=btn_Save runat=server Text=Save OnClick=btn_Save_Click/> I
I have a Gridview with these parameters: <asp:GridView runat=server ID=ItemGrid CssClass=Grid AutoGenerateColumns=false AutoGenerateDeleteButton=true OnRowDeleting=RowDeleting
I have the folling Gridview column <asp:TemplateField HeaderText=Installed Date SortExpression=install_date> <EditItemTemplate> <asp:TextBox ID=gvtxtInstalledDate runat=server
I have an ASP.NET page with a gridview control on it with a CommandButton
Have a gridview control which will show X amount of rows. I want to
I have two cascading dropdowns and one gridview control. on page load iam binding
Using asp.net 3.5 Gridview control, visual studio 2008. I have played with all the

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.