Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 05, 2012 12:59 AM by CruzerB
Dec 05, 2012 12:53 AM|LINK
My question is lets say I have a database with ID,FName,LName,Middle,Address1,Address2,City,State,ZIP,HomePhone,CellPhone,BusinessAddr1,.....
So i create a class called PersonDetails.cs with all the properties I just listed.
Now I have another class called DatabaseOperations.cs and I create a List collection of my person object that calls a storedprocedure and then uses a sqldatareader to read through my properties, does every property have to display in my datagrid or is there
a way in order to just show ID,FName,LName and ignore the rest of the properties without creating a new class that just holds those 3 properties?
Because what is happening is that even though my StoredProcedure is only returning ID,Fname,Lname and my sqldatareader only has those 3 properties it still displays every property in my gridview
Hope I explained that correctly if not please let me know and will try and elaborate a little more.
Dec 05, 2012 12:59 AM|LINK
Are you looking to display selective columns at Gridview? If it is, then you can set AutoGenerateColumns
property of Gridview to false and define the columns that you want them to display.
Please refer to http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.autogeneratecolumns.aspx