Click here to Skip to main content
11,484,752 members (63,700 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# LINQ
Hii all..,

I have a gridview

here i want to find the specific row of a gridview.
how can i achieve this.

Thanx in advance..
Venkatesh..
Posted 25-Jan-13 0:40am
Comments
ujju.1 at 25-Jan-13 5:44am
   
details please
Abhishek Pant at 25-Jan-13 5:56am
   
how are you using search for gridview.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

int RowIndex = ((GridViewRow)lbtn.NamingContainer).RowIndex;


or


void gvName_RowCommand(Object sender, GridViewCommandEventArgs e)
    {
    // If multiple click event control are used then used commandname property of that control
     if(e.CommandName=="Add")
     {
           // Convert the row index stored in the CommandArgument property to     an Integer.
          int index = Convert.ToInt32(e.CommandArgument);
 
          // Retrieve the row that contains the button clicked by the user from the Rows collection.
         GridViewRow row = CustomersGridView.Rows[index];
 
   
     }
    
}

or


protected void gvName_RowUpdating(object sender, GridViewUpdateEventArgs e)
   {
 
       int RowIndex = e.RowIndex;
 
   }
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Below is the code

string cellValue = mydatagrid["columnName",rowindex].Value.ToString();

Hope this helps if yes then accept this as solution and vote it otherwise revert back with your queries
--RDB
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,

Please try this

Label myLabel = (Label)myGridView.Rows[myGridView.SelectedIndex].Cells[2].FindControl("myLabel"); 

this might be help for you...
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Hi,
you may try this.

private DataGridViewRow GetSpecificRow(object uniqueId)
{
    foreach (DataGridViewRow item in dataGridView1.Rows)
    {
        if (item.Cells["UniqueId"] == uniqueId)
            return item;
    }
    return null;
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

 
GridViewRow row=(GridViewRow)GridView1.Rows[e.Rowindex];
 
int id=Convert.toInt32(Gridview1.Datakeys[e.RowIndex].Value); \\for datakey value
 
Label lbl=(Label)row.findcontrol("lblid"); \\ Find a Specific control.
  Permalink  

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

  Print Answers RSS
0 Maciej Los 190
1 Sergey Alexandrovich Kryukov 180
2 Raje_ 155
3 OriginalGriff 147
4 Mehdi Gholam 120
0 Sergey Alexandrovich Kryukov 8,494
1 OriginalGriff 7,948
2 Sascha Lefèvre 3,199
3 Maciej Los 2,681
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 27 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100