The Artima Developer Community
Sponsored Link

.NET Buzz Forum
ASP.NET DataGrid's AutoGenerateColumns doesn't add the BoundColumns to the Columns collection...

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Samer Ibrahim

Posts: 55
Nickname: ibrahimss
Registered: Aug, 2003

Samer Ibrahim is a .NET programmer... I really don't want a long bio
ASP.NET DataGrid's AutoGenerateColumns doesn't add the BoundColumns to the Columns collection... Posted: Feb 13, 2004 4:30 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Samer Ibrahim.
Original Post: ASP.NET DataGrid's AutoGenerateColumns doesn't add the BoundColumns to the Columns collection...
Feed Title: Samer Ibrahim's Blog
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/SIbrahim/Rss.aspx
Feed Description: The Samer I Warrior on battles with .NET
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Samer Ibrahim
Latest Posts From Samer Ibrahim's Blog

Advertisement

While I ordinarily set AutoGenerateColumns = false on ASP.NET DataGrids, I finally found a pretty good use for them.  I had a result set that was coming back with a variable number of columns all of which need to be display.  I thought what a perfect use for the auto-generating columns but low and behold I discovered the documentation says:

Note   Explicitly declared columns may be used in conjunction with auto-generated columns. When using both, explicitly declared columns will be rendered first, followed by the auto-generated columns. Auto-generated columns are not added to the Columns collection.

The hell kind of garbage is that?!?!  Why aren't Auto-generated columns added to the Columns collection?!?!?  Shouldn't they abide by the same rules other columns do?  After all, aren't they just BoundColumn's?  All I wanted to do was simply set the DataFormatString property on them.  What an annoyance!  Instead I had to check the number of columns in the IDataReader using the FieldCount property and then programmatically creating each column and set the format.  But then what is the point of the AutoGenerateColumns property?  Has anyone ever used it in a real world application?  Oh well.....

Read: ASP.NET DataGrid's AutoGenerateColumns doesn't add the BoundColumns to the Columns collection...

Topic: Appweak... Previous Topic   Next Topic Topic: Elections

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use