Click here to Skip to main content
12,444,237 members (44,113 online)
Rate this:
 
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 24-Jan-13 23:40pm
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: 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 27 Jan 2013
Copyright © CodeProject, 1999-2016
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