Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

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



or


C#
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


C#
protected void gvName_RowUpdating(object sender, GridViewUpdateEventArgs e)
   {

       int RowIndex = e.RowIndex;

   }
 
Share this answer
 
v2
Comments
[no name] 27-Jan-13 6:54am    
+5
Below is the code

C#
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
 
Share this answer
 
Hi,

Please try this

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


this might be help for you...
 
Share this answer
 
Hi,
you may try this.

C#
private DataGridViewRow GetSpecificRow(object uniqueId)
{
    foreach (DataGridViewRow item in dataGridView1.Rows)
    {
        if (item.Cells["UniqueId"] == uniqueId)
            return item;
    }
    return null;
}
 
Share this answer
 
C#
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.
 
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