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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:18:00+00:00 2026-05-23T16:18:00+00:00

I have a GridView which I am filling with data from my database. The

  • 0

I have a GridView which I am filling with data from my database. The data displays perfectly. My problem is that I want to be able to click on a row and then display the information that is in that row elsewhere (eventually I’ll have a splitscreen to format the selected data nicely). The selection works, because it highlights the current row. However, I cannot figure out how to display that data elsewhere. For now, I’m trying to display the content of a single cell in a label called testLabel. I’ve tried many different methods, and the testLabel never updates when I click a new row. Can anybody see what is going wrong here?

C#

protected void DefaultGrid_SelectedIndexChanged(Object sender, EventArgs e)
{
    GridViewRow row = DefaultGrid.SelectedRow;
    testLabel.Text = row.Cells[2].Text;
}

ASPX

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID = "ScriptManager" runat="server" />
    <div>
        <div>
            <asp:Label runat="server" id = "orderByLabel" Text = "Order By: " />


            <asp:DropDownList runat="server" ID="orderByList" AutoPostBack="true">
                <asp:ListItem Value="fName" Selected="True">First Name</asp:ListItem>
                <asp:ListItem Value="lName">Last Name</asp:ListItem>
                <asp:ListItem Value="state">State</asp:ListItem>
                <asp:ListItem Value="zip">Zip Code</asp:ListItem>
                <asp:ListItem Value="cwaSource">Source</asp:ListItem>
                <asp:ListItem Value="cwaJoined">Date Joined</asp:ListItem>
            </asp:DropDownList>
        </div>
        <div>
            <asp:Label runat="server" ID="searchLabel" Text="Search For: " />
            <asp:TextBox ID="searchTextBox" runat="server" Columns="30" />
            <asp:Button ID="searchButton" runat="server" Text="Search" />
        </div>
    <div align="center">
    <asp:UpdatePanel ID = "up" runat="server">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID = "orderByList"
        EventName="SelectedIndexChanged" />
         <asp:AsyncPostBackTrigger ControlId="searchButton" EventName="Click" />
    </Triggers>

    <ContentTemplate>
        <asp:GridView ID="DefaultGrid" runat = "server" DataKeyNames = "fName"
        onselectedindexchanged = "DefaultGrid_SelectedIndexChanged"
        autogenerateselectbutton = "true"
        selectedindex="0">
        <SelectedRowStyle BackColor="Azure"
        forecolor="Black"
        font-bold="true" />
        <Columns>
            <asp:ButtonField CommandName="Select" Visible="false" />
        </Columns>
        </asp:GridView>
        </ContentTemplate>
        </asp:UpdatePanel>



    </div>
    </div>
    <div>
        <asp:Label runat="server" ID="testLabel" Text="test" />
    </div>
    </form>
</body>
</html>
  • 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-23T16:18:00+00:00Added an answer on May 23, 2026 at 4:18 pm

    You have provided own select button and also set property http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.autogenerateselectbutton.aspx to true. You must choose only one of those.

    Edit: Ah, see it now. Label ‘testLabel’ is outside updatepanel. Move it to ContentTemplate.

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

Sidebar

Related Questions

I have a GridView which retrieves data from a database. Users have roles, some
I have a GridView which binds data from DB, and using rowboundevent, I want
I have a gridview which is databound, I want to dynamically add a row
I have a gridview which displays data for all employees and their images (stored
In my aspx page I have a gridview which displays the value from my
I have a gridview which is pulling it data from a stored procedure. In
I have a gridview which successfully binds to the database and gets all data.
I have a GridView which you can click on a row and it should
I have a GridView which is populated from a database, and includes a textbox.
I Have a gridview which has a row that contains LinkButtons that were added

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.