会话添加需要澄清 [英] Session Add need clarification

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

问题描述

 grdStudent.DataSource = ds.Tables [ 0 ]; 
grdStudent.DataBind();

lblConnectionState.Text = 返回的结果;

}

受保护 void grdStudent_SelectedIndexChanged(< span class =code-keyword> object sender,EventArgs e)
{
// GridViewRow row = new GridViewRow();

Session.Add( last_name,grdStudent.SelectedRow.Cells [ 1 ]。Text);
Session.Add( other_names,grdStudent.SelectedRow.Cells [ 2 ]文本);
Session.Add( marital_status,grdStudent.SelectedRow.Cells [ 3 ]文本);

if (IsPostBack)
{
txtLastname.Text = Session [ last_name]。ToString();
txtOthernames.Text = Session [ other_names]。ToString();
ddlMaritalStatus.SelectedValue = Session [ marital_status]。ToString();

}
}







请澄清行< br $>


1.



< pre lang =cs> grdStudent .DataSource =  ds.Tables [0] ; 





什么是表[0]





2.



  Session.Add (& quot; last_name& quot;,grdStudent.SelectedRow.Cells [1] .Text); 







谢谢

解决方案

1。名为grdStudent的网格视图与数据集的第一个数据表中的数据绑定;通过这种方式,网格中填充了数据,但数据必须存在于数据集中。



2.在此行中,来自第一列的数据当前选定的网格行被缓存到用户会话中;用户 Session 是用于在当前用户的bostback之间缓存数据的字典,在此行中,此条目的键是 last_name ;请注意,将使用您的Web应用程序的每个用户都将关联一个单独的会话,仅供他/她使用。


grdStudent.DataSource = ds.Tables[0];
       grdStudent.DataBind();

       lblConnectionState.Text = "RESULTS RETURNED";

   }

   protected void grdStudent_SelectedIndexChanged(object sender, EventArgs e)
   {
       //GridViewRow row = new GridViewRow();

       Session.Add("last_name", grdStudent.SelectedRow.Cells[1].Text);
       Session.Add("other_names", grdStudent.SelectedRow.Cells[2].Text);
       Session.Add("marital_status", grdStudent.SelectedRow.Cells[3].Text);
     
       if (IsPostBack)
       {
           txtLastname.Text = Session["last_name"].ToString();
           txtOthernames.Text = Session["other_names"].ToString();
          ddlMaritalStatus.SelectedValue = Session["marital_status"].ToString();
       
       }
   }




please clarify the line

1.

<pre lang="cs">grdStudent.DataSource = ds.Tables[0];



what is Tables[0]


2.

Session.Add(&quot;last_name&quot;, grdStudent.SelectedRow.Cells[1].Text);




Thanks

解决方案

1. Your grid view named grdStudent is bound with the data from the first data table of your data set; in this way the grid is filled with data, but the data must exist in your data set.

2. In this line, the data from the first column of the current selected row of the gird is cached into the user session; The user "Session" is a dictionary for caching data between bostbacks for the current user, and in this line the key for this entry is "last_name"; Note that each user that will use your web application will have associated a separate "Session" used only by him/her.


这篇关于会话添加需要澄清的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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