Converting BoundFields from tags to code

P

Pete

Hi - In DetailsView I want to convert the bound <Fields> from tags to
code so the fields can be picked up from the schema. I tried
converting:
<asp:BoundField ReadOnly="True" HeaderText="CustomerID"
DataField="CustomerID" SortExpression="CustomerID"></asp:BoundField>
by using:
DetailsView1.Fields.Add(New BoundField)
DetailsView1.Fields(0).HeaderText = "CustomerID"
DetailsView1.Fields(0).SortExpression = "CustomerID"
but I that way can't set the BoundField's DataField or its ReadOnly
value. Help on how to convert to code would be very much appreciated.
-Pete
 
P

Pete

Hi - In DetailsView I want to convert the bound <Fields> from tags to
code so the fields can be picked up from the schema. I tried
converting:
<asp:BoundField ReadOnly="True" HeaderText="CustomerID"
DataField="CustomerID" SortExpression="CustomerID"></asp:BoundField>
by using:
DetailsView1.Fields.Add(New BoundField)
DetailsView1.Fields(0).HeaderText = "CustomerID"
DetailsView1.Fields(0).SortExpression = "CustomerID"
but I that way can't set the BoundField's DataField or its ReadOnly
value. Help on how to convert to code would be very much appreciated.
-Pete

Addendum: The point in replacing tags with code is so that
"CustomerID," for example, can be replaced by SchemaFields(0) and the
great long list of fields can be replaced by a simple code loop. This
satisfies several dictates of good design. I am surprised that msdn2
seems to be going toward tags-only illustrations rather than both tags
and code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top