473,503 Members | 7,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help: PageDataSource, Repeater and Codebehind function...

Roy
I have a problem with displaying data from a repeater where the data has to
be converted in a function. The repeater with PagedDataSource works fine and
all data is displayed except the columns where the function is executed.

sample of html code

<tr>
<td width="150">Delprosjekt</td>
<td><%#getvalue(container.itemindex,"DelProsjekt") %></td>
</tr>

sample code behind function

Public Function getValue(ByVal value As Int32, ByVal strColumn As
String) As String

Dim strValue As String
strValue =
DsBilder1.Tables("Bilder").Rows(value).Item(strCol umn).ToString
If strValue = "" Then strValue = "&nbsp"
getValue = strValue
End Function

I know this only works on the first page because the itemindex is correct in
the PagedDataSource and the Dataset. The problem araise in page 2 and up.
I just dont know how i can read the correct row based on the itemindex
returned from the binded PagedDataSource.

Should i read the data from the PagedData or from the Dataset? If so how do
i read this from the PagedData?

TIA
--
Roy
Nov 19 '05 #1
2 3054
There are a couple simple posibilities...like get get the # of records per
page, and the page number and add that to value...so if you have 10 records
per page and you are on page 2 and value = 2 you want the 12th record ((2 -
1) * 10) + 2

((p - 1) * #) + value

a solution which is 10x better is to simply pass in the row as a parameter:

<%# GetValue(Container.DataItem, "DelProsjekt") %>

public function GetValue(row as DataViewRow, column as String) as string
dim value = Convert.ToString(row(column))
....
end function
or something similar....Container.DataItem will be of type DataViewRow only
when you are binding to a dataset, datatable or dataview.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Roy" <Ro*@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
I have a problem with displaying data from a repeater where the data has to be converted in a function. The repeater with PagedDataSource works fine and all data is displayed except the columns where the function is executed.

sample of html code

<tr>
<td width="150">Delprosjekt</td>
<td><%#getvalue(container.itemindex,"DelProsjekt") %></td>
</tr>

sample code behind function

Public Function getValue(ByVal value As Int32, ByVal strColumn As
String) As String

Dim strValue As String
strValue =
DsBilder1.Tables("Bilder").Rows(value).Item(strCol umn).ToString
If strValue = "" Then strValue = "&nbsp"
getValue = strValue
End Function

I know this only works on the first page because the itemindex is correct in the PagedDataSource and the Dataset. The problem araise in page 2 and up.
I just dont know how i can read the correct row based on the itemindex
returned from the binded PagedDataSource.

Should i read the data from the PagedData or from the Dataset? If so how do i read this from the PagedData?

TIA
--
Roy

Nov 19 '05 #2
Roy
Thanx.. That worked just great. DataRowView did the trick.

"Karl Seguin" wrote:
There are a couple simple posibilities...like get get the # of records per
page, and the page number and add that to value...so if you have 10 records
per page and you are on page 2 and value = 2 you want the 12th record ((2 -
1) * 10) + 2

((p - 1) * #) + value

a solution which is 10x better is to simply pass in the row as a parameter:

<%# GetValue(Container.DataItem, "DelProsjekt") %>

public function GetValue(row as DataViewRow, column as String) as string
dim value = Convert.ToString(row(column))
....
end function
or something similar....Container.DataItem will be of type DataViewRow only
when you are binding to a dataset, datatable or dataview.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Roy" <Ro*@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
I have a problem with displaying data from a repeater where the data has

to
be converted in a function. The repeater with PagedDataSource works fine

and
all data is displayed except the columns where the function is executed.

sample of html code

<tr>
<td width="150">Delprosjekt</td>
<td><%#getvalue(container.itemindex,"DelProsjekt") %></td>
</tr>

sample code behind function

Public Function getValue(ByVal value As Int32, ByVal strColumn As
String) As String

Dim strValue As String
strValue =
DsBilder1.Tables("Bilder").Rows(value).Item(strCol umn).ToString
If strValue = "" Then strValue = " "
getValue = strValue
End Function

I know this only works on the first page because the itemindex is correct

in
the PagedDataSource and the Dataset. The problem araise in page 2 and up.
I just dont know how i can read the correct row based on the itemindex
returned from the binded PagedDataSource.

Should i read the data from the PagedData or from the Dataset? If so how

do
i read this from the PagedData?

TIA
--
Roy


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2041
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
0
1528
by: Kent P. Iler | last post by:
Hi, I have a data repeater that is returning a list of events. One of the things I want to do is give the user a way to edit or delete an event. My plan was to use an Imagebutton that would...
8
2371
by: darrel | last post by:
*sigh*...I've asked this before, but have long forgotten the answer. In the past, I'd often use repeater controls, bind data to it, and then reference the data fields from within the repeater: ...
4
1441
by: TheBurgerMan | last post by:
Hi all. I have an array of objects (Let's call it Object A) and each of these objects has an array of other objects (Let's call these Object B) in it. I can successfully repeat through Object A's...
1
6391
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
4
5098
by: jjack100 | last post by:
I have a DropDownList that is nested inside a Repeater. The datasource of the DropDownList is declared in the aspx, not the codebehind. So we have this: <asp:Repeater ID="rptOptions"...
0
2781
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
0
2253
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
0
1984
by: simon | last post by:
hello, relatively new to .net, i'm using vb.net and the 2.0 .net platform I'm trying to display a grid that has a text box on the left in one cell (with a hidden ID), which will be associated...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.