Solved 2.0 how to reference a detailsview field in another text box

Posted on 2006-05-18
Last Modified: 2010-05-18
I used the data DetailsView control to quickly make an updateable details view.  It works great.
However I would like to referece an field that is being displayed.

I can do it wity a view: GridView2.SelectedRow.Cells.Item(1).Text
But how do I do the same with a detailsview??

Question by:nutrino149
    LVL 11

    Accepted Solution

    //each row corresponds to a BoundField on the DetailsView definition
     //Row(1) is the second field:  it renders a cell that has a
     //textbox in it.
     TextBox txt= (TextBox)DetailsView1.Rows[1].Cells[1].Controls[0];

     //if you placed your controls within ItemTemplates then you would just
     //call the FindControl with the ID you gave that control, e.g, if you
     //had placed in the markup
     //<asp:HiddenField ID="key1" runat="server" />
     //Then you would refer to it like this:

      HiddenField  hid= (HiddenField)detailsView1.FindControl("key1");

    I founf this here:

    Author Comment

    I wish to apologize, I have been away for an emergency for about a month.

    Sorry about not getting back to my questions.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 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

    7 Experts available now in Live!

    Get 1:1 Help Now