如何使用Gridview按钮保持会话中的上一个值单击 [英] How to keep the previous value in session using Gridview button click

查看:83
本文介绍了如何使用Gridview按钮保持会话中的上一个值单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我单击Gridview的按钮,则它将在会话中选择该值并显示在另一个Gridview中,如果再次单击,则将显示两个值.

if i will click button of a Gridview then it will select that value in session and display in another gridview and again if i will click then that will display the both value.

推荐答案

将上一个会话的值分配给另一个会话变量.然后更新该会话的值...并像执行您的要求一样...
Assign the value of previous session to another session variable..Then update the value of that session...And do as if your reqmt...


我已经写了像这样,它显示当前索引值.但是我想在gridview3中存储和显示prvs,当前值.

在pageLoad中写入:
如果(Session ["shoppingSession"] == null)
{
ds = new DataSet();

Session ["shoppingSession"] = ds;
}
其他
{
ds =(DataSet)Session ["shoppingSession"];
ad = new SqlDataAdapter("select * from REG where Stu_Reg =""+ str +",cn);
ds = new DataSet();
ad.Fill(ds,"REG");
GridView3.DataSource = ds;
GridView3.DataBind();
}

***********
在Row_Command中:





如果(e.CommandName =="Show")
{
GridViewRow grv =(GridViewRow)((Button)e.CommandSource).NamingContainer;
按钮btn =(Button)GridView1.Rows [grv.RowIndex] .FindControl("Button1");
GridView grd2 =(GridView)GridView1.Rows [grv.RowIndex] .FindControl("GridView2");

str = GridView1.Rows [grv.RowIndex] .Cells [0] .Text;
如果(btn.Text =="Expand")
{
ad = new SqlDataAdapter("select * from REG where Stu_Reg =""+ str +"",cn);
ds = new DataSet();
ad.Fill(ds,"REG");
GridView3.DataSource = ds;
GridView3.DataBind();
}
}
i have written like this and it is displaying the current index value.but i want to store and display prvs ,current value in gridview3.

Within pageLoad written:
if (Session["shoppingSession"] == null)
{
ds = new DataSet();

Session["shoppingSession"] = ds;
}
else
{
ds = (DataSet)Session["shoppingSession"];
ad = new SqlDataAdapter("select *from REG where Stu_Reg= ''"+ str +"'', cn);
ds = new DataSet();
ad.Fill(ds, "REG");
GridView3.DataSource = ds;
GridView3.DataBind();
}

***********
Within Row_Command:





if (e.CommandName == "Show")
{
GridViewRow grv = (GridViewRow)((Button)e.CommandSource).NamingContainer;
Button btn = (Button)GridView1.Rows[grv.RowIndex].FindControl("Button1");
GridView grd2 = (GridView)GridView1.Rows[grv.RowIndex].FindControl("GridView2");

str = GridView1.Rows[grv.RowIndex].Cells[0].Text;
if (btn.Text == "Expand")
{
ad = new SqlDataAdapter("select *from REG where Stu_Reg=''" + str + "''", cn);
ds = new DataSet();
ad.Fill(ds, "REG");
GridView3.DataSource = ds;
GridView3.DataBind();
}
}


这篇关于如何使用Gridview按钮保持会话中的上一个值单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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