嗨..
我有一个gridview有column_NameTable_Name,我有一个linkbutton.I想要当我点击链接按钮然后页面重定向
到其他页面和选定的行值(Table_Name)存储在会话变量中。我尝试但它不工作。它重定向到其他页面,但
值不存储在会话中。
我尝试过:
这是我的aspx.cs代码:
protected void PassData( object sender,EventArgs e)
{
GridViewRow gr =((sender as LinkButton).NamingContainer as GridViewRow);
会话[ TBL_NAME] = gr.Cells [ 1 跨度>] Text.Trim();
Response.Redirect( ModifyTable.aspx);
}
这是我的aspx代码:
< asp:TemplateField >
< ItemTemplate >
< asp:LinkButton ID = lnkSelect runat = server 文本 = 详细信息 C ommandName = 选择 data-tablename =' <% #Eval( Table_Name)%>' OnClick = PassData / >
< / ItemTemplate >
< / asp:TemplateField >
解决方案
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:
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:TemplateField> <ItemTemplate> <asp:LinkButton ID="lnkSelect" runat="server" Text="Detail" CommandName="Select" data-tablename='<%# Eval("Table_Name") %>' OnClick="PassData" /> </ItemTemplate> </asp:TemplateField>解决方案
这篇关于如何在会话变量中存储linkbutton gridview选择的行值? Asp.net C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!