Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bind only few porperties of an object to datagrid.

Status
Not open for further replies.

JeetSingh

MIS
Joined
May 12, 2005
Messages
7
Location
US
Hi,
I have an object with 15 properties and i want to bind only 5 of them to various ccolumns in a datagrid.
How can i do that.

right now when i bind the object to the grid , it shows all the 15 colummns. i need only 5 and the columns to be displayed are known at design time.
Any code snippet or link to an article would be greatly appreciated.

Thanks.
 
I could hide the columns but the problem is if i do that i have more than 400 rows and the page would be really heavy plus i have viewstate on so.. want to avoid that any otehr solution.....
 
Only pull back the columns that you need instead of the 15
 
how do i do that ?
because i pull back 5 columns in a datareader and then update the properties of the boject (only 5 of them) and then bind the object to grid.
so where i shoudl take care of that
could you please elaborate
thanks
 
Use the IDE, Right click on the datagrid use the "property builder". Under "columns" uncheck "Create Columns automatically at run time". Then you need to add the "bound columns" you want to show up.
 
stsuing's suggestion is good. You can always just modify your SQL to pull back the 5 columns you want
 
Guys i am not getting the columns as resultset or dataset
I have an object which has 15 properties and i am binding that object to the grid so there is no question of SQL....

OK let me put it this way.
the only place the sql is used is when i get the cursor with 5 columsn once i get these 5 columns i update my object as this object inherits from another class even those columns are shown in the grid i want to avoid those columns and show only the columns that are there in the new object

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top