Solved

How do I pull a value from a DetailsView

Posted on 2009-04-01
9
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Set arraylist as datatable 2 28
Shared Service Environment 2 54
Convert a string to date 4 40
EMAIL RANGES BASED ON CURRENT TIME 12 37
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

737 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