Solved

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

Posted on 2012-03-11
3
381 Views
Last Modified: 2012-03-12
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>.
0
Comment
Question by:Eindoofus
  • 2
3 Comments
 
LVL 12

Expert Comment

by:Alfredo Luis Torres Serrano
ID: 37709365
GridView1.AutoGenerateColumns = true;
 GridView1.AutoGenerateSelectButton = true;
0
 

Author Comment

by:Eindoofus
ID: 37710592
Thanks, do I put that into the Page_Load method?
0
 
LVL 12

Accepted Solution

by:
Alfredo Luis Torres Serrano earned 500 total points
ID: 37710958
Yes it could be, At page load method

If !page.ispostback then
GridView1.AutoGenerateColumns = true;
 GridView1.AutoGenerateSelectButton = true;
endif
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now