Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
:(( How to get more selectdata from a gridview's
Posted
Comments
Mohd Wasif 21-Oct-10 1:11am    
Just Clarify Ur answer
Mohd Wasif 21-Oct-10 1:11am    
means ur question what do u want.
Rajesh Anuhya 21-Oct-10 1:17am    
you mean multi selection of rows in gridview??
Ankur\m/ 21-Oct-10 1:35am    
Read the guidelines.
Abhinav S 21-Oct-10 1:39am    
What are you looking for?

Depends on how you have your GridView setup.

If you want to get the data on click of a single button at the bottom of the page you would need to loop each of the DataGridRow in GridView1.Rows and search for the relavant control using FindControl().

Another way is to have a button on each row (so a edit or delete style button). Instead of looping thru each of the rows. You can use the ItemCommand event available to the GridView.

If you require examples of these methods please let me know.
 
Share this answer
 
Because you already know the row your after this is no need to loop the collection.

You should be able to do something like the following.

void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    GridViewRow selectedRow = GridView1.SelectedRow;

    Label label = (Label)selectedRow.FindControl("Label1");
}
 
Share this answer
 
v2
C#
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
   {

C#
foreach (GridViewRow row in rowArray)
   {
   j++;
           if (j == GridView1.SelectedRow.RowIndex)
   {
   Label2.Text = row.Cells[5].Text;
            }

       }





lable 7.text is empty


return 0 in run program




OR TYPE THIS CODE

GridViewRow row = GridView1.SelectedRow;
Label2 .Text = row.Cells[2].Text;


in this code label7.text is empty plz help me:confused: :((
 
Share this answer
 
Comments
Rajesh Anuhya 21-Oct-10 5:32am    
i was fully confused by your answer.., where this lable7 is came., what is this return 0 in run program ..,
is it answer or question???

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