Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i need get the value of gridview praticular cell when edit button is clicked.

how to do ?
Posted
Comments
Mycroft Holmes 9-Aug-11 5:54am    
You really should let us know whether you are using windows forms or asp or WPF/SL as the methods are very different.

Try the below

C#
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        //following will iterate all rows
        foreach (GridViewRow row in GridView1.Rows)
        {
            string value = row.Cells[DesiredcolumnIndex].Text;
        }
        //following will give the value of single row that is being edited
        int i = e.NewEditIndex;
        string value = GridView1.Rows[i].Cells[DesiredcolumnIndex].Text;
    }
 
Share this answer
 
v2
Comments
RaviRanjanKr 9-Aug-11 4:25am    
Nice Answer, My 5+
something linke this

GridView.Rows.Cells[i]

i=index
 
Share this answer
 
Comments
MDubey1987 9-Aug-11 3:45am    
It will be-

GridView.Rows[i].Cells[j]
where i=row index
j=cell index

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