• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 590
  • Last Modified:

asp.net 2.0 how to reference a detailsview field in another text box

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??

1 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:
nutrino149Author Commented:
I wish to apologize, I have been away for an emergency for about a month.

Sorry about not getting back to my questions.
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now