Click here to Skip to main content
15,904,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
GridViewRow row = GridView1.Rows[e.RowIndex];

       if (Session["dt"] != null)
       {
           DataSet dt1 = (DataSet)Session["dt"];
           dt1.Tables[0].Rows[row.DataItemIndex][0] = ((TextBox)(row.Cells[1].Controls[0])).Text;
           dt1.Tables[0].Rows[row.DataItemIndex][1] = ((TextBox)(row.Cells[2].Controls[0])).Text;
           dt1.Tables[0].Rows[row.DataItemIndex][2] = ((TextBox)(row.Cells[3].Controls[0])).Text;
           dt1.Tables[0].Rows[row.DataItemIndex][3] = ((TextBox)(row.Cells[4].Controls[0])).Text;
           GridView1.EditIndex = -1;
           binddata();
       }

       if (Session["key"] != null)
       {
           Response.Write("hello");
           DataSet dt2 = (DataSet)Session["key"];
           dt2.Tables[0].Rows[row.DataItemIndex][0] = ((TextBox)(row.Cells[1].Controls[0])).Text;
           dt2.Tables[0].Rows[row.DataItemIndex][1] = ((TextBox)(row.Cells[2].Controls[0])).Text;
           dt2.Tables[0].Rows[row.DataItemIndex][2] = ((TextBox)(row.Cells[3].Controls[0])).Text;
           dt2.Tables[0].Rows[row.DataItemIndex][3] = ((TextBox)(row.Cells[4].Controls[0])).Text;
           GridView1.EditIndex = -1;
           binddata();
       }

only the first row is updated well for others i found error There is no row at position 1 in session["key"].. (the session["dt"] is working well it is an empty dataset")
Posted
Updated 4-Feb-11 19:40pm
v3

1 solution

Well, error simple states that Session["key"] has a dataset that has only one row in it.

You need to use DEBUGGER and see yourself what is stored in Session["key"]; and verify that it stored a dataset that has more that many rows as much you expect and have written code for. (Here 4 rows expected)
 
Share this answer
 
Comments
gowdhami 5-Feb-11 3:41am    
i used debugger also if i click update in second row it was showing the error in session["dt"].
dt1.Tables[0].Rows[row.DataItemIndex][0] = ((TextBox)(row.Cells[1].Controls[0])).Text;
Sandeep Mewara 5-Feb-11 4:07am    
As per error your Session["key"] has issues and contains only 1 row. After putting debugger check what is stored in session.

Earlier you said there was no issues with Session["dt"] ... now you say you do. :doh:
gowdhami 5-Feb-11 4:55am    
while updating the second row value from session["key"] it was showing the error session["dt"]. dt1.Tables[0].Rows[row.DataItemIndex][0] = ((TextBox)(row.Cells[1].Controls[0])).Text;
but while updating the session["key"] there was no error... now also i am saying that there is no issue while updating session["dt"]
Espen Harlinn 6-Feb-11 11:04am    
Good answer, I suspect that OP expects the data to propagate to all the sessions, and would be better served by using the cache :)

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