本文介绍了将数组存储到会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何在会话中添加数组?有办法吗?继承我的代码:



 protected void CompetencyRetrieve(object sender,EventArgs e)
{
int index = Convert。 ToInt32(maxindex.Text); // ERROR HERE

DropDownList box1 =(DropDownList)Gridview1.Rows [index] .Cells [1] .FindControl(DropDownList1);
DropDownList box2 =(DropDownList)Gridview1.Rows [index] .Cells [2] .FindControl(DropDownList2);
DropDownList box3 =(DropDownList)Gridview1.Rows [index] .Cells [3] .FindControl(DropDownList3);

var Trainings = DataService.Instance.getTraining(box2.Text,box1.Text);
if(Trainings.Rows.Count!= 0)
{
box3.DataSource = Trainings;
box3.DataTextField =ProgramsDesc;
box3.DataValueField =Programs_id;
box3.DataBind();

//此处会话

}
其他
{
box3.Items.Clear();
}


}





每次这个功能触发器,将添加数组的条目,然后存储在会话中。任何帮助?

解决方案

Hi,

how can I add an array to a session? is there a way to do it? heres my code:

protected void CompetencyRetrieve(object sender, EventArgs e)
   {
       int index = Convert.ToInt32(maxindex.Text); // ERROR HERE

           DropDownList box1 = (DropDownList)Gridview1.Rows[index].Cells[1].FindControl("DropDownList1");
           DropDownList box2 = (DropDownList)Gridview1.Rows[index].Cells[2].FindControl("DropDownList2");
           DropDownList box3 = (DropDownList)Gridview1.Rows[index].Cells[3].FindControl("DropDownList3");

           var Trainings = DataService.Instance.getTraining(box2.Text, box1.Text);
           if (Trainings.Rows.Count != 0)
           {
               box3.DataSource = Trainings;
               box3.DataTextField = "ProgramsDesc";
               box3.DataValueField = "Programs_id";
               box3.DataBind();

               //session here

           }
           else
           {
               box3.Items.Clear();
           }


   }



each time that this function triggers, an entry to the array will be added, then stored inside a session. any help?

解决方案


这篇关于将数组存储到会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:13