Converting BoundFields from tags to code

Discussion in 'ASP .Net Web Controls' started by Pete, Sep 17, 2007.

  1. Pete

    Pete Guest

    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
     
    Pete, Sep 17, 2007
    #1
    1. Advertising

  2. Pete

    Pete Guest

    On Sep 17, 4:34 pm, Pete <> 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.
     
    Pete, Sep 18, 2007
    #2
    1. Advertising

  3. Pete

    Pete Guest

    I figured it out. Sorry to have taken up space.

    -Pete
     
    Pete, Sep 18, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christina

    How do I Email DetailsView BoundFields

    Christina, Dec 8, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    377
    Christina
    Dec 8, 2006
  2. ami
    Replies:
    0
    Views:
    321
  3. helveticus

    Localizing BoundFields

    helveticus, Dec 2, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    359
    helveticus
    Dec 2, 2008
  4. JB
    Replies:
    3
    Views:
    2,047
    Alexey Smirnov
    Oct 21, 2009
  5. jonefer

    Dynamically boundfields aren't really dynamic

    jonefer, May 23, 2007, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    755
    jonefer
    May 23, 2007
Loading...

Share This Page