Solved

How do I pull a value from a DetailsView

Posted on 2009-04-01
9
174 Views
Last Modified: 2012-05-06
ASP.NET 2.0/VB.NET 2.0 and sql server 05: How do I pull a value from a DetailsView?
0
Comment
Question by:techpr0
  • 5
  • 4
9 Comments
 
LVL 23

Accepted Solution

by:
apresto earned 500 total points
ID: 24039666
As in from a control or just a cell?
Cell : DetailsView1.Rows(0).Cells(1).Text
Control : DetailsView1.FindControl("ControlName").Text
0
 

Author Comment

by:techpr0
ID: 24041195
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
 

Author Comment

by:techpr0
ID: 24041263
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 23

Expert Comment

by:apresto
ID: 24041655
Sorry, in order to get the Text Property you need to convert it to TextBox:

((Textbox)DetailsView1.FindControl("ControlName")).Text
0
 
LVL 23

Expert Comment

by:apresto
ID: 24041677
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
 

Author Comment

by:techpr0
ID: 24043232
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
 
LVL 23

Expert Comment

by:apresto
ID: 24044813
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
 

Author Closing Comment

by:techpr0
ID: 31565321
Thanks for your help. I couldn't have done it without your helpl.
0
 
LVL 23

Expert Comment

by:apresto
ID: 24108400
Very glad that i was able to help in some way :)
Apresto
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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