Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

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?
0
techpr0
Asked:
techpr0
  • 5
  • 4
1 Solution
 
aprestoCommented:
As in from a control or just a cell?
Cell : DetailsView1.Rows(0).Cells(1).Text
Control : DetailsView1.FindControl("ControlName").Text
0
 
techpr0Author Commented:
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?
0
 
techpr0Author Commented:
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?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
aprestoCommented:
Sorry, in order to get the Text Property you need to convert it to TextBox:

((Textbox)DetailsView1.FindControl("ControlName")).Text
0
 
aprestoCommented:
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
0
 
techpr0Author Commented:
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?
0
 
aprestoCommented:
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?
0
 
techpr0Author Commented:
Thanks for your help. I couldn't have done it without your helpl.
0
 
aprestoCommented:
Very glad that i was able to help in some way :)
Apresto
0
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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