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

  • Home
  • SEARCH
  • 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 7493053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:43:37+00:00 2026-05-29T16:43:37+00:00

How can I select all data from GridView s current row.. I have a

  • 0

How can I select all data from GridViews current row..
I have a column for edit link in GridView. When “Edit” link button is clicked, I want to use that selected row’s data. I am trying the following code, but it’s returning me with an empty value

protected void gv_RowEditing(object sender, GridViewEditEventArgs e)
{
    gv.EditIndex = -1;
    GridViewRow gvRow = gv.Rows[ e.NewEditIndex];
    string selectedID = gvRow.Cells[3].Text;
}

                 <asp:GridView runat = "server" ID="gvRange0" SkinID="gridView"                AutoGenerateColumns="False"  
                            AllowSorting="True"   OnRowCancelingEdit="gvRange_RowCancelingEdit" OnRowDeleting="gvRange_RowDeleting"
                            OnRowEditing="gvRange_RowEditing" OnRowUpdating="gvRange_RowUpdating" 
                                Width="684px"  OnRowDataBound="gvRange_RowDataBound"  
                            DataMember="DefaultView" OnPageIndexChanged="gvRange_PageIndexChanged" 
                            OnPageIndexChanging="gvRange_PageIndexChanging" OnSorting="gvRange_Sorting" DataKeyNames = "RANGE_ID" 
                            OnSelectedIndexChanged="gvRange_SelectedIndexChanged" Height="65px" >
                              <Columns>
                                  <asp:TemplateField ShowHeader="False">
                                      <ItemTemplate>
                                      <ControlStyle Width="2px" />
                                          <asp:LinkButton ID="lnkDelete0" runat="server" CssClass="lnk" 
                                              CausesValidation="False" CommandName="Delete"
                                              Text="Delete" Visible="false"></asp:LinkButton>
                                          <asp:CheckBox runat="server" ID="chkSelect" CssClass="lbl" Text="" AutoPostBack="False" OnCheckedChanged="chkSelect_CheckedChanged" />
                                      </ItemTemplate>
                                  </asp:TemplateField>
                                  <asp:TemplateField ShowHeader="False">
                                    <ItemTemplate>
                                    <controlStyle width="2px" />
                                      <asp:LinkButton ID="lnkEdit" runat="server" CssClass="lnk" CausesValidation="False" CommandName="Edit"
                                        Text="Edit" ></asp:LinkButton>

                                    </ItemTemplate>
                                    <ItemStyle Width="5px" />
                                  </asp:TemplateField>
                                  <asp:TemplateField HeaderText="Ranges" SortExpression="Sort_Ranges">
                                      <ControlStyle Width="5px" />
                                      <ItemTemplate>
                                      <%#DataBinder.Eval(Container.DataItem,"Min_Age") %>

                                      <%# CheckNull(DataBinder.Eval(Container.DataItem,"Max_Age")) %>
                                      </ItemTemplate>
                                     <%-- <ItemTemplate>--%>
                                          <%--<asp:Label ID="lblStageName" CssClass="lbl" runat="server" Text='<%# Bind("Age_Range") %>' Width="1px"></asp:Label>--%>
                                    <%--  </ItemTemplate>--%>
                                  </asp:TemplateField>
                                  <asp:TemplateField HeaderText="Range ID">
                                  <ItemTemplate><%#DataBinder.Eval(Container.DataItem,"RANGE_ID") %></ItemTemplate>
                                  </asp:TemplateField>
                              </Columns>                        
                          </asp:GridView>

There are 4 columns in the GridView. One contains check box, second is link button for edit, third databound with some value, fourth is the column which I want to use to get some values from database(that is primary key there) and this column is hidden.

  • 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-29T16:43:52+00:00Added an answer on May 29, 2026 at 4:43 pm

    I’ve noticed that you say you need to access the 4th column but you’re using gvRow.Cells[3].Text;

    The indexing in the Cell object is done from 1, so if you need to access the 4th row in the grid view try this:

    string selectedID = gvRow.Cells[4].Text;
    

    EDIT:

    Could you please confirm two things for me

    1)When you click on lnkEdit is the GridView1_RowEditing event being raised?

    2)If yes, is the e.NewEditIndex value always showing up as ‘0’?
    Attempt clicking the edit link on different rows, is the result always ‘0’?

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

Sidebar

Related Questions

I have a Gridview in my page Which I can Select each row i
I have a gridview which shows all the information of the data table. I
As I know, the SELECT syntax is used for getting data from a row
I have a gridview that imports data from a remote database, this is working
The following code fetch all data (by clicking a.info link) from a php file
I am trying to select all data from oracle table where emp_id = emp_id_in
I have a GridView using LinqDataSource to populate data from table Tickets . The
Hey guys, I have an application that I want to display some data from
I want to do following: Make Oracle stored procedure for read all data from
I had used the SqlDataSource to retrieve data from database to gridview. <asp:SqlDataSource ID=SqlDataSource1

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.