Click here to Skip to main content
15,887,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a GridView. On the basis of rows selected from that Gridview I have to fetch the selected data from the GridView and display that data in a TextBox.

How can I do that?
Posted
Updated 12-May-11 0:09am
v2
Comments
R. Giskard Reventlov 12-May-11 6:09am    
What have you tried for yourself?
Sandeep Mewara 12-May-11 6:28am    
So what is the issue? Where are you stuck?

Hope this works for you


TextBox2.Text = GridView1.SelectedRow.RowIndex.ToString();

or

textbox.text = GridView1.SelectedRow.Cells[2].Text;

The array id may change depending on the cell u want to retrieve.
 
Share this answer
 
You can add one button for selecting the grid view row.

Then add Command name and command argument property in to this button as
Commandname="Select" Commandargument='<%#(GridviewRow.(Container. RowIndex))%>'

Then add the event row command
Then check if (e.commandname=="select")
u can get the row index by
int index=convert.toInt32(e.commandargument.tostring());


u can select any value from selected row in a gridview as
label lbl=(label)gridview1.rows[index].findcontrol("ControlName");
textbox1.text=lbl.text;
 
Share this answer
 

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