Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..
I have a gridview having column_Name "Table_Name" and i have a linkbutton.I want that when i click on link button then page redirect
to other page and selected row value (Table_Name) store in session variable.I try but it's not working.It redirect to other page but
value not store in session.

What I have tried:

Here is my aspx.cs code:
C#
protected void PassData(object sender, EventArgs e)
{
 GridViewRow gr = ((sender as LinkButton).NamingContainer as GridViewRow);
 Session["TBL_NAME"] = gr.Cells[1].Text.Trim();
 Response.Redirect("ModifyTable.aspx");
} 

here is my aspx code:
ASP.NET
<asp:TemplateField>
            <ItemTemplate>
                <asp:LinkButton ID="lnkSelect" runat="server" Text="Detail" CommandName="Select"  data-tablename='<%# Eval("Table_Name") %>' OnClick="PassData" />
            </ItemTemplate>
        </asp:TemplateField>
Posted
Updated 28-May-16 22:23pm

1 solution

try this

C#
protected void PassData(object sender, EventArgs e)
       {
           var linkButton = (sender as LinkButton);
           var tableName = linkButton.Attributes["data-tablename"];
           Session["TBL_NAME"] = tableName;
           Response.Redirect("ModifyTable.aspx");
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900