Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Help: PageDataSource, Repeater and Codebehind function...

Reply
Thread Tools

Help: PageDataSource, Repeater and Codebehind function...

 
 
=?Utf-8?B?Um95?=
Guest
Posts: n/a
 
      01-11-2005
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
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      01-11-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Um95?=
Guest
Posts: n/a
 
      01-11-2005
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding to a Repeater in Codebehind...a little confusion. nobody@somewhere.com ASP .Net 2 03-22-2005 06:15 AM
Repeater not found in C# codebehind Jon ASP .Net 1 01-13-2005 05:06 PM
Help! Having trouble calling codebehind function from repeater results! Kent P. Iler ASP .Net Web Controls 0 03-07-2004 11:04 PM
Help! Having trouble calling codebehind function from repeater results! Kent P. Iler ASP .Net Datagrid Control 0 03-07-2004 11:04 PM
Help! Having trouble calling codebehind function from repeater results! Kent P. Iler ASP .Net 0 03-07-2004 11:04 PM



Advertisments