Home All Groups Group Topic Archive Search About

Converting BoundFields from tags to code

Author
17 Sep 2007 8:34 PM
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

Author
18 Sep 2007 10:51 AM
Pete
On Sep 17, 4:34 pm, Pete <sign***@msu.edu> wrote:
> 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.
Author
18 Sep 2007 9:30 PM
Pete
I figured it out.  Sorry to have taken up space.

-Pete

AddThis Social Bookmark Button