I am trying to open other page and pass data for selected row in gridview to be displayed in that page when user click the select button. i want to display the data in text box. so that, user can make editing from that page. i dont know how to pass the data for that selected row to be displayed in other page. Can someone help me??

Recommended Answers

All 2 Replies

>i dont know how to pass the data for that selected row to be displayed in other page. Can someone help me??

Use Session state.

Click handler of button of page1.aspx

Session["firstname"]=textbox1.Text;
Session["lastname"]=textbox2.Text;

Page_load handler of page2.aspx

if(!IsPostBack){
   if(Session["firstname"]!=null) 
          TextBox1.Text=Session["firstname"].ToString();

   if(Session["lastname"]!=null) 
          TextBox1.Text=Session["lastname"].ToString();

  }

do one thing, before binding gridview with datatable or dataset, store whole datatable or dataset in Session.

Now I assume you have select button for each row in gridview. So you can pass the ID of particular row in query string of the page you want to open.

Now in page2, just cast session into datatable or dataset whatever you are using. Also store fetch ID from query string and pass it in tables Select() method. The Select() method of DataTable return array of DataRow.

So once you have data in datarow array, you can assign value from it to your textbox on page.

hope this will help you..


I am trying to open other page and pass data for selected row in gridview to be displayed in that page when user click the select button. i want to display the data in text box. so that, user can make editing from that page. i dont know how to pass the data for that selected row to be displayed in other page. Can someone help me??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.