Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Dynamically boundfields aren't really dynamic

Thread Tools

Dynamically boundfields aren't really dynamic

Posts: n/a
I found this code in ASP.NET forum

It's the first code that actually built the grid the way I wanted with the
sortfields on only certain columns

However... the columns don't get rebuilt between searches
so it errors out - when there is a result set with less columns
I thought that was the reason for the dynamic bound columns

How can I make sure that it starts fresh everytime the search button is

For Each dc As DataColumn In ds.Tables(0).Columns
Dim bField As BoundField = New BoundField

'Initalize the DataField value.
bField.DataField = dc.ColumnName

'Initialize the HeaderText field value.
bField.HeaderText = dc.ColumnName
If Left(dc.ColumnName, 14) = "General Course" Then
bField.SortExpression = dc.ColumnName
End If
'Add the newly created bound field to the GridView.

gvActionList.DataSource = ds
Me.lblCheck.Text = ""

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Match width of column heading in row with GridView BoundFields in JB ASP .Net 3 10-21-2009 05:05 PM
Localizing BoundFields helveticus ASP .Net 1 12-02-2008 09:51 PM
Converting BoundFields from tags to code Pete ASP .Net Web Controls 2 09-18-2007 09:30 PM
Dynamically Adding Boundfields + Sorting ami ASP .Net 0 04-25-2007 06:15 PM
How do I Email DetailsView BoundFields Christina ASP .Net 0 12-08-2006 09:34 PM