Click here to Skip to main content
14,327,888 members
Rate this:
Please Sign up or sign in to vote.
See more:
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
Comments
ujju.1 25-Jan-13 5:44am
   
details please
Abhishek Pant 25-Jan-13 5:56am
   
how are you using search for gridview.
Rate this:
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;

   }
   
v2
Comments
sisir patro 27-Jan-13 6:54am
   
+5
Rate this:
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
   
Rate this:
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...
   
Rate this:
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;
}
   
Rate this:
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.
   

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




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