how to get the value of a field in a detailsview?

Discussion in 'ASP .Net Building Controls' started by Chris, Jul 28, 2007.

  1. Chris

    Chris Guest

    I need the value of a field of a detailsview in DataBound event.
    i can find the fieldname with this:
    Dim a As DataControlField
    a = DetailsView1.Fields(0)

    But how to get the value of that field?
    i tried a lot of things without succes:
    Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles DetailsView1.DataBound
    dim enqna as DetailsViewRow
    enqna = DetailsView1.DataItem

    or

    dim enqna As DataColumn
    enqna= DetailsView1.DataItem
    .....
    or
    Dim va As String
    va = DetailsView1.Controls.Item(1).ToString

    Thanks for help
    Chris
     
    Chris, Jul 28, 2007
    #1
    1. Advertising

  2. Chris

    chenhong Guest

    you could get the value of the field by get the value of the corresponding
    label control value of the field.
    the lable load event should do the trick.

    "Chris" <> дÈëÏûÏ¢ÐÂÎÅ:...
    >I need the value of a field of a detailsview in DataBound event.
    > i can find the fieldname with this:
    > Dim a As DataControlField
    > a = DetailsView1.Fields(0)
    >
    > But how to get the value of that field?
    > i tried a lot of things without succes:
    > Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles DetailsView1.DataBound
    > dim enqna as DetailsViewRow
    > enqna = DetailsView1.DataItem
    >
    > or
    >
    > dim enqna As DataColumn
    > enqna= DetailsView1.DataItem
    > ....
    > or
    > Dim va As String
    > va = DetailsView1.Controls.Item(1).ToString
    >
    > Thanks for help
    > Chris
    >
     
    chenhong, Jul 29, 2007
    #2
    1. Advertising

  3. Chris

    Chris Guest

    Hi, thanks for replying.
    I ommit to mention that the fields are templatefields, like this:
    <asp:TemplateField SortExpression="enqna">
    <EditItemTemplate>
    <asp:Label ID="Label1" runat="server" Text='<%# Eval("enqna")
    %>'></asp:Label>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label1a" runat="server" Text='<%# Bind("enqna")
    %>'></asp:Label>
    </ItemTemplate>
    <ItemStyle Font-Bold="True" Font-Size="Larger" HorizontalAlign=Center />
    </asp:TemplateField>

    So there is no 'label1a' load event (the value i'm interesting it).
    Thanks

    "chenhong" <> schreef in bericht
    news:Oj2$...
    > you could get the value of the field by get the value of the corresponding
    > label control value of the field.
    > the lable load event should do the trick.
    >
    > "Chris" <>
    > дÈëÏûÏ¢ÐÂÎÅ:...
    >>I need the value of a field of a detailsview in DataBound event.
    >> i can find the fieldname with this:
    >> Dim a As DataControlField
    >> a = DetailsView1.Fields(0)
    >>
    >> But how to get the value of that field?
    >> i tried a lot of things without succes:
    >> Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
    >> System.EventArgs) Handles DetailsView1.DataBound
    >> dim enqna as DetailsViewRow
    >> enqna = DetailsView1.DataItem
    >>
    >> or
    >>
    >> dim enqna As DataColumn
    >> enqna= DetailsView1.DataItem
    >> ....
    >> or
    >> Dim va As String
    >> va = DetailsView1.Controls.Item(1).ToString
    >>
    >> Thanks for help
    >> Chris
    >>

    >
    >
     
    Chris, Jul 29, 2007
    #3
  4. Chris

    chenhong Guest

    this question is the same as your another question,
    see the reply there.


    "Chris" <> дÈëÏûÏ¢ÐÂÎÅ:...
    > Hi, thanks for replying.
    > I ommit to mention that the fields are templatefields, like this:
    > <asp:TemplateField SortExpression="enqna">
    > <EditItemTemplate>
    > <asp:Label ID="Label1" runat="server" Text='<%# Eval("enqna")
    > %>'></asp:Label>
    > </EditItemTemplate>
    > <ItemTemplate>
    > <asp:Label ID="Label1a" runat="server" Text='<%# Bind("enqna")
    > %>'></asp:Label>
    > </ItemTemplate>
    > <ItemStyle Font-Bold="True" Font-Size="Larger" HorizontalAlign=Center />
    > </asp:TemplateField>
    >
    > So there is no 'label1a' load event (the value i'm interesting it).
    > Thanks
    >
    > "chenhong" <> schreef in bericht
    > news:Oj2$...
    >> you could get the value of the field by get the value of the
    >> corresponding label control value of the field.
    >> the lable load event should do the trick.
    >>
    >> "Chris" <> дÈëÏûÏ¢ÐÂÎÅ:...
    >>>I need the value of a field of a detailsview in DataBound event.
    >>> i can find the fieldname with this:
    >>> Dim a As DataControlField
    >>> a = DetailsView1.Fields(0)
    >>>
    >>> But how to get the value of that field?
    >>> i tried a lot of things without succes:
    >>> Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
    >>> System.EventArgs) Handles DetailsView1.DataBound
    >>> dim enqna as DetailsViewRow
    >>> enqna = DetailsView1.DataItem
    >>>
    >>> or
    >>>
    >>> dim enqna As DataColumn
    >>> enqna= DetailsView1.DataItem
    >>> ....
    >>> or
    >>> Dim va As String
    >>> va = DetailsView1.Controls.Item(1).ToString
    >>>
    >>> Thanks for help
    >>> Chris
    >>>

    >>
    >>

    >
    >
     
    chenhong, Jul 29, 2007
    #4
  5. Chris

    Chris Guest

    This has been solved.
    Thanks for your help.



    "chenhong" <> schreef in bericht
    news:%...
    > this question is the same as your another question,
    > see the reply there.
    >
    >
    > "Chris" <>
    > дÈëÏûÏ¢ÐÂÎÅ:...
    >> Hi, thanks for replying.
    >> I ommit to mention that the fields are templatefields, like this:
    >> <asp:TemplateField SortExpression="enqna">
    >> <EditItemTemplate>
    >> <asp:Label ID="Label1" runat="server" Text='<%# Eval("enqna")
    >> %>'></asp:Label>
    >> </EditItemTemplate>
    >> <ItemTemplate>
    >> <asp:Label ID="Label1a" runat="server" Text='<%# Bind("enqna")
    >> %>'></asp:Label>
    >> </ItemTemplate>
    >> <ItemStyle Font-Bold="True" Font-Size="Larger" HorizontalAlign=Center />
    >> </asp:TemplateField>
    >>
    >> So there is no 'label1a' load event (the value i'm interesting it).
    >> Thanks
    >>
    >> "chenhong" <> schreef in bericht
    >> news:Oj2$...
    >>> you could get the value of the field by get the value of the
    >>> corresponding label control value of the field.
    >>> the lable load event should do the trick.
    >>>
    >>> "Chris" <>
    >>> дÈëÏûÏ¢ÐÂÎÅ:...
    >>>>I need the value of a field of a detailsview in DataBound event.
    >>>> i can find the fieldname with this:
    >>>> Dim a As DataControlField
    >>>> a = DetailsView1.Fields(0)
    >>>>
    >>>> But how to get the value of that field?
    >>>> i tried a lot of things without succes:
    >>>> Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
    >>>> System.EventArgs) Handles DetailsView1.DataBound
    >>>> dim enqna as DetailsViewRow
    >>>> enqna = DetailsView1.DataItem
    >>>>
    >>>> or
    >>>>
    >>>> dim enqna As DataColumn
    >>>> enqna= DetailsView1.DataItem
    >>>> ....
    >>>> or
    >>>> Dim va As String
    >>>> va = DetailsView1.Controls.Item(1).ToString
    >>>>
    >>>> Thanks for help
    >>>> Chris
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Chris, Jul 29, 2007
    #5
    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. Chris
    Replies:
    4
    Views:
    5,402
    Chris
    Jul 29, 2007
  2. =?Utf-8?B?Q2hhcmxlc19t?=

    Get value of a field in detailsview

    =?Utf-8?B?Q2hhcmxlc19t?=, Sep 26, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    439
    =?Utf-8?B?Q2hhcmxlc19t?=
    Sep 26, 2007
  3. Sound
    Replies:
    2
    Views:
    465
    Randy Webb
    Sep 28, 2006
  4. VUNETdotUS
    Replies:
    25
    Views:
    473
    Thomas 'PointedEars' Lahn
    Nov 10, 2007
  5. jr
    Replies:
    3
    Views:
    448
Loading...

Share This Page