Click here to Skip to main content
16,022,417 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I am using a gridview which is suppose to read the data inside the rows. But I am getting the above error Error 1 Non-invocable member 'System.Web.UI.WebControls.GridView.Rows' cannot be used like a method.

C#
protected void GridView1_SelectedIndexChanged(object sender, System.EventArgs e)
   {

       Int32 index = GridView1.SelectedIndex;
       lblrep.Text = GridView1.Rows(index).Cells(2).Text;
       btndownload.Enabled = true;


   }


the error appears in the word 'Rows'
Posted

In C#, "()" means calling a function, "[]" means "get by index". Your Rows is the property to provide access to each raw by index, so use "[]".

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 29-Sep-11 21:40pm    
Nice reply :)
Sergey Alexandrovich Kryukov 30-Sep-11 0:25am    
Thank you, Espen.
--SA
C#
protected void GridView1_SelectedIndexChanged(object sender, System.EventArgs e)
   {

       Int32 index = GridView1.SelectedIndex;
       lblrep.Text = GridView1.Rows[index].Cells[2].Text;
       btndownload.Enabled = true;


   }


You are using an array with these ( ) instead of these [ ].

() for VB
[] for C#
 
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