Click here to Skip to main content
15,896,450 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can Any One Tell This Code is Correct for retriving Cell reord when selecting on linkbutton in Gridview...
C#
protected void GridViewteam_RowCommand(object sender, GridViewCommandEventArgs e)
       {
        
           try
           {
               String id = e.CommandArgument.ToString();

               if (e.CommandName.Equals("SelectRecord"))
               {

                   GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
                   String tcode = row.Cells[1].Text;
                   String tnm = row.Cells[2].Text;
                   String sdesc = row.Cells[3].Text;

                   Label1.Text = sdesc;
                   Label2.Text = tnm;
                   Label3.Text = tcode;

               }

           }
           catch (Exception ex)
           {
               throw ex;
           }





     }
Posted
Comments
Naz_Firdouse 13-Oct-15 6:18am    
any issues with this code???
ASPDevloper 13-Oct-15 6:20am    
ya ....not give any value of cell.
ASPDevloper 13-Oct-15 6:20am    
only return blank value..
Arasappan 13-Oct-15 6:22am    
Label1.Text = sdesc.Text;
ASPDevloper 13-Oct-15 6:24am    
String sdesc = row.Cells[3].Text;
this use after that assign .

1 solution

String tcode = row.Cells[1].Text;
String tnm = row.Cells[2].Text;
String sdesc = row.Cells[3].Text;


replace below code with above

String tcode = GridView1.Rows[0].Cells[0].Text;
String tnm = GridView1.Rows[0].Cells[1].Text;
String sdesc = GridView1.Rows[0].Cells[2].Text;
 
Share this answer
 
v2

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