Solved

Get the detailsview value

Posted on 2007-04-04
6
1,244 Views
Last Modified: 2008-01-09
A column in my detailsview contains an id, i'd like to use this id as part of a link on the page.
I've been messing about with a label trying to get this value but am falling short...
code behind
label1.text = detailsview. ???????
0
Comment
Question by:QPR
[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
  • 4
6 Comments
 
LVL 4

Accepted Solution

by:
vitjan earned 300 total points
ID: 18853927
Hi QPR,

I am just guessing what you really need.
Would this work for you:
label1.text = DetailsView1.Rows[0].Cells[0].Text

Regards,
Jan

0
 
LVL 29

Author Comment

by:QPR
ID: 18854217
"detailsview collection cannot be converted to type string"
0
 
LVL 29

Author Comment

by:QPR
ID: 18854616
I think the [0] should be (0) ?
This way I don't get "squiggles"

However when I use it I now get
System.ArgumentOutOfRangeException was unhandled by user code
  Message="Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
  ParamName="index"
  Source="mscorlib"
 
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 5

Assisted Solution

by:mzalewski
mzalewski earned 200 total points
ID: 18854643
Is this code being executed after the data is bound to the detailsview?
vitjan posted C# code, you must be using VB.NET?

"Index was out of range" tells me that either the Rows or Cells Collection is empty. This could be because you have placed this code before any databinding code.

You can check the count of the collections like this
if (DetailsView1.Rows.Count > 0 && DetailsView1.Rows[0].Cells.Count > 0)
0
 
LVL 29

Author Comment

by:QPR
ID: 18854663
I have no "code behind" other than what I am trying to do with the lable.
When is a detailsview databound?
Which event should I use to make sure that I only try to populate the label when the detailsview is populated?
 <asp:DetailsView ID="DetailsView1" runat="server" BackColor="#DEBA84"
            BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2"
            DataSourceID="SqlDataSource1" Height="50px" Width="488px" AutoGenerateRows="False" DataKeyNames="propno">
0
 
LVL 29

Author Comment

by:QPR
ID: 18854709
Solved, the problem was that when I launched from VS2005 there was no querystring data.
This data was needed to populate the detailsview.
I changed the start page when launching and by navigating to the page in question (with querystring data) I was able to get it to work.

And yes vb.net not C# - sorry I should have specified.
0

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.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…
Suggested Courses

710 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