Avatar of Eindoofus
Eindoofus
 asked on

How to enable Selection for a GridView that assigns the DataSource in the code behind class?

Hi, I noticed that when I create a GridView that I am given the option to "Enable Selection" as long as I choose a DataSource in the GUI. However, I am binding the DataSource in the code behind class.

I added SelectMethod="GetCustomers" to my GridView control and an empty GetCustomers() method to my code behind class but I don't see a "Select" link appear in my GridView.

How can I enable "Selection" for my GridView if the DataSource is being bound in the code behind?

Not sure if this is relevant but my data is coming from my NorthwindDAL.GetCustomers() method which is returning a List of type <Customers>.
C#.NET ProgrammingASP.NET

Avatar of undefined
Last Comment
Alfredo Luis Torres Serrano

8/22/2022 - Mon
Alfredo Luis Torres Serrano

GridView1.AutoGenerateColumns = true;
 GridView1.AutoGenerateSelectButton = true;
Eindoofus

ASKER
Thanks, do I put that into the Page_Load method?
ASKER CERTIFIED SOLUTION
Alfredo Luis Torres Serrano

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy