DetailView values


I have a DetailView and I added a LinkButton to it in the footer. The detail view is binded to a datasource with a SELECT query to retrieve some values from a table. When I click my button in the DetailView, I need to access the values displayed in the current page of the DetailView and save it in string variables. How do I get those values? Should I act on DetailView object or on DataSource object or what else? This is possible to do, isn't it?

Who is Participating?
GreymanMSCConnect With a Mentor Commented:
Either use Hiddenfields, or bind the button's CommandArgument to hold the string you wish to use (and use the OnCommand event rather than the OnClick event to process things.

Something like this:
<asp:Button ID=Clicky runat=server 
    OnCommand="Clicky_Command" Text="Click Me" CommandName="ClickMe" 
    CommandArgument='<%# "FirstID:" & Eval("FirstID") & ";SecondID:" & Eval("SecondID") %>'     

Open in new window

Then do, maybe something like this:
Protected Sub Clicky_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
   Dim Values() As String = e.CommandArgument.Split(";")
   For Each Value As String In Values
        Dim Pair() As String = Value.Split(":")
        '...maybe store them somewhere
   ' something
End Sub

Open in new window

ziggie301Author Commented:
Sorry I don't understand.. I don't understand vb. Maybe I dind'nt formulate my question correctly.

Is there a way to locate VALUES shown by the DetailsView component in a particular DetailsView Page?
ziggie301Author Commented:
Sorry I was in a hurry and very nervous.. This was perfect. Thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.