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

C

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
 
C

chenhong

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.
 
C

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
 

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,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top