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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:11:18+00:00 2026-06-13T23:11:18+00:00

i have a gridview like this : <asp:GridView ID=wbsdataGV1 runat=server Width=790px AutoGenerateColumns=False OnSelectedIndexChanged=wbsdataGV1_SelectionChanged> <Columns>

  • 0

i have a gridview like this :

 <asp:GridView ID="wbsdataGV1" runat="server" Width="790px" AutoGenerateColumns="False"
                                    OnSelectedIndexChanged="wbsdataGV1_SelectionChanged">
                                    <Columns>

                                        <asp:TemplateField HeaderText="WBS Code">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval("WBSCode") %>'></asp:LinkButton>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Description">
                                            <ItemTemplate>
                                                <asp:TextBox ID="TextBox7" runat="server" Text='<%# Eval("Description") %>'></asp:TextBox>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Territory Code">
                                            <ItemTemplate>
                                                <asp:TextBox ID="TextBox8" runat="server" Text='<%# Eval("TerritoryCode") %>'></asp:TextBox>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Amount">
                                            <ItemTemplate>
                                                <asp:TextBox ID="TextBox9" runat="server" Text='<%# Eval("AmountReleased") %>'></asp:TextBox>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>

when i am clicking on the linkbutton i want that data and i will transfer that to another aspx from .. through

protected void wbsdataGV1_SelectionChanged(object sender, EventArgs e)
{
    //Some code ;
}

now my question is how i can get that data by clicking the linkbutton on gridview ? i can transfer the data by querystring or session variable or hidden text field … but my concern is that how can i get the exact clicked data…
any help?

  • 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-13T23:11:19+00:00Added an answer on June 13, 2026 at 11:11 pm

    Define the DataKeys attribute to the be primary key of your data (here I assume you have a row identifier called “ID”.

    <asp:GridView ... DataKeys="ID">
        ... existing markup
    </asp:GridView>
    

    In wbsdataGV1_SelectionChanged, get back the ID of the row the user clicked like this:

    int rowID = (int)this.wbsdataGV1.SelectedDataKey.Value;
    

    Then redirect to another page like this, passing just the ID:

    Response.Redirect("anotherpage.aspx?id=" + rowID);
    

    Then in your other page:

    protected void Page_Load(object s, EventArgs e)
    {
        if (!Page.IsPostback)
        {
            int rowID = int.Parse(Request.QueryString["id"]);
    
            // do something with the ID of the row, like go and look
            // up JUST that row again
        }
    }
    

    Bonus – to make the whole row clickable, avoiding the need for a CommandButton, do this:

    <script language="javascript" type="text/javascript">
        var oldColour = null;
    
        function rowMouseover(o) {
            o.style.cursor = 'pointer';
            oldColour = o.style.backgroundColor;
            o.style.backgroundColor = '#dddddd';
        }
    
        function rowMouseout(o) {
            o.style.backgroundColor = oldColour;
        }
    </script>
    
    <asp:GridView ... OnRowCreated="grid_RowCreated" />
    
    protected void grid_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onclick"] =
                Page.ClientScript.GetPostBackClientHyperlink(
                    this.grid, 
                    "Select$" + e.Row.RowIndex);
    
            e.Row.Attributes["onmouseover"] = "rowMouseover(this);";
            e.Row.Attributes["onmouseout"] = "rowMouseout(this);";
        }
    }
    
    protected override void Render(HtmlTextWriter writer)
    {
        for (int i = 0; i < grid.Rows.Count; i++)
            Page.ClientScript.RegisterForEventValidation(grid.UniqueID, "Select$" + i); 
    
        base.Render(writer);
    }
    

    You could pass the ID via the Session object, but you’d get odd behaviour with more than one browser window doing the same operation at the same time (depending on the browser). This would be hard for a user to tamper with.

    You could pass the ID via Request.Form too, that would hide it from trivial user fiddling but doesn’t add any true security.

    Protip: don’t just dump massive objects into the Session variable. It’s lazy, error prone, and doesn’t scale.

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

Sidebar

Related Questions

I have a simple grid view like this : <asp:GridView ID=gv_userActivities runat=server AutoGenerateColumns=False> <Columns>
I have a GridView like this <asp:GridView ID=gv_FilesList runat=server AutoGenerateColumns=false onrowcommand=gv_FilesList_RowCommand> <Columns> <asp:BoundField DataField=f_Id
so I have a GridView like this: <asp:GridView ID=gv runat=server AutoGenerateColumns=False GridLines=None OnRowCommand=gv_RowCommand OnRowDeleting=gv_RowDeleting
I have a GridView just like this: <asp:GridView ID=gvwStudents runat=server AutoGenerateColumns=False DataKeyNames=ID ShowHeader=False onrowdeleting=gvwStudents_RowDeleting>
hi I have this gridview like this. <asp:DropDownList ID=triggerDropDown runat=server AutoPostBack=true onselectedindexchanged=triggerDropDown_SelectedIndexChanged> <asp:GridView ID=myGridView
I have the following gridview: <asp:GridView ID=gdvReport runat=server AutoGenerateColumns=False DataSourceID=sdseport> <Columns> <asp:BoundField DataField=Phone HeaderText=Phone
I have a GridView, <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False DataSourceID=SqlDataSource1> <Columns> <asp:BoundField DataField=LastName HeaderText=LastName SortExpression=LastName
I have a gridview like this. <asp:GridView ID=grdMerchant runat=server GridLines=None HeaderStyle-Font-Bold=True AutoGenerateColumns=False AllowSorting=True ShowHeader=false
I have my <asp:GridView ID=gridView runat=server> I bind it like this : myConnection.Open(); SqlCommand
Ok so I have a GridView like this: <asp:GridView ID=gv runat=server ... > ...

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.