c#中gridview选择中的会话值 [英] Session values in gridview selection in c#

查看:107
本文介绍了c#中gridview选择中的会话值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai,



我有一个gridview.I有一个疑问。我有Incident.aspx网页。它正在插入值到sql.And我正在使用事件链接按钮显示Home.aspx页面。如果我们单击事件链接按钮,它将显示事件相关的gridview.Suppose如果我们在gridview中选择选择按钮,它将转到事件.aspx并且必须显示所选行的会话值。我不知道如何实现这一点.Plz帮助我。





在此先感谢

Hai,

I am having a gridview.I have one doubt.I am having "Incident.aspx" webpage.It is inserting values into sql.And I am having "Home.aspx" page with Incident Link button.If we click the incident link button it will show the Incident related gridview.Suppose if we select a "select" button inside the gridview it will go to "incident .aspx" and have to show the session values for the selected row.I do no how it can be achieve this.Plz help me.


Thanks in advance

推荐答案

为选择添加一个事件, OnSelectedIndexChanging =OnRowSelected



然后在您的代码中:

Add an event for the selection, OnSelectedIndexChanging="OnRowSelected".

Then in your code behind:
protected void OnRowSelected(object sender, GridViewSelectEventArgs e)
{
    var currentGridViewRow = GridView.SelectedRow;

    //You can insert to the session information about this row:   
    Session["currentGridViewRow"] = currentGridViewRow;

    // Redirect to Incident page
    Response.Redirect("Incident.aspx");
}



之后,在您的 Incident.aspx 页面代码后面,您可以获取信息来自会话。


After that, in your Incident.aspx page code behind, you can get the information from the session.

var currentGridViewRow = Session["currentGridViewRow"];


这篇关于c#中gridview选择中的会话值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆