DetailView values

Posted on 2008-11-10
Last Modified: 2013-12-17

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?

Question by:ziggie301
    LVL 16

    Accepted Solution

    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

    LVL 16

    Expert Comment

    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


    Author Comment

    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?

    Author Closing Comment

    Sorry I was in a hurry and very nervous.. This was perfect. Thank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now