Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
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
Posted
Updated 27-Jun-14 23:07pm
v2

1 solution

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.
 
Share this answer
 
Comments
Member 10744248 28-Jun-14 5:37am    
what is Tables[0]

WHY [O]
Member 10744248 28-Jun-14 5:41am    
SORRY I GOT IT
VICK 30-Jun-14 3:27am    
if this solution helps you clear your points, do accept it formally as a solution to bring your question/post out of the UNAnswered.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900