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.
Are you looking to display selective columns at Gridview? If it is, then you can set AutoGenerateColumnsproperty 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
No matter how much time you spend on coding. Wish you happy coding.
My Technical Blog
Marked as answer by jakhtar on Dec 05, 2012 01:53 AM
JAkhtar
Member
32 Points
24 Posts
Having trouble grasping c# properties {get : set}
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.
CruzerB
Contributor
5399 Points
1098 Posts
Re: Having trouble grasping c# properties {get : set}
Dec 05, 2012 12:59 AM|LINK
Hi,
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
My Technical Blog