Link to home
Start Free TrialLog in
Avatar of techpr0
techpr0Flag for United States of America

asked on

How do I pull a value from a DetailsView

ASP.NET 2.0/VB.NET 2.0 and sql server 05: How do I pull a value from a DetailsView?
ASKER CERTIFIED SOLUTION
Avatar of apresto
apresto
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of techpr0

ASKER

VS was telling me that DetailsView1.FindControl("ControlName") doens't have a text property. But when I watch DetailsView1.FindControl("ControlName") the value is listed as {Text="Data Im looking for"}. So what I did was:
 
Dim lbl As Label = dvCustomer.FindControl("Label1")

Then used lbl.Text to get me the value. As far as you know, is this the best way to do this?
Avatar of techpr0

ASKER

Is it possible to, when filling my form with these DetailsView on it,  use this DetailsView Template field to hold the value retreived from the database? Or should I just hide the DetailsView and use a textbox?
Sorry, in order to get the Text Property you need to convert it to TextBox:

((Textbox)DetailsView1.FindControl("ControlName")).Text
Obviously change "Textbox" to the relevant Control
If you are going to use a Details View, use it to its full potential and use the TemplateField, if the DetailsView is generally unnecessary use a textbox. But if you have to hide a details view, i would suggest you dont hide it and use the templatefield
Avatar of techpr0

ASKER

Good, I'm on the right track. I am using a template field but how do I assign something to the template field without binding it to a datasource?
Im not entirely sure what you mean, but to be honest my knowledge on this is limited, i could answer your initial question but maybe its best you start another question for this. Assuming your initial question has been answered? Did you manage to get the value from the cell?
Avatar of techpr0

ASKER

Thanks for your help. I couldn't have done it without your helpl.
Very glad that i was able to help in some way :)
Apresto