Question : Getting gridview column value in button click

                            AllowSorting="True" OnPageIndexChanging="GridView2_PageIndexChanging" OnSorting="GridView2_Sorting"
                            PageSize="2">
                           

   
                                   
                                       
                                   

                                   




I want to write onclick code for link button and get the value of  Fnumber.
Please help

Answer : Getting gridview column value in button click

here it is, there are two solutions, use either one...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
        
            
                
                
            
        

    protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Select")
        {
            /* use this format or one below
            int index = Convert.ToInt32(e.CommandArgument);
            GridViewRow selectedRow = GridView2.Rows[index];
            TableCell tcFNumber = selectedRow.Cells[0];
            String Fnumber = tcFNumber.Text;
            */
            DataRowView rowView = (DataRowView)e.Row.DataItem;
            String Fnumber = rowView["Fnumber"].ToString();
        }
    }
Random Solutions  
 
programming4us programming4us