Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - finding repeateritem which matches a fieldvalue

 
Thread Tools Search this Thread
Old 01-04-2005, 03:39 PM   #1
Default finding repeateritem which matches a fieldvalue


Hi there, I have a brain block on finding a repeater item which matches a
field from the row of the datasource. If my datasource has a column called
'somethingid' i want to find the repeateritem which has somethingid=1 (there
will only be one)

so I have set up an iterator

foreach (RepeaterItem item in myrepeater.Items)
{
//below is what i am trying to do but this doesnt work, not sure of syntax
if (item.dataitem["somethingid"]=="1") {

do something

}
}

Not sure what syntax to use. I'm sure its pretty simple. Thank you.


=?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=
  Reply With Quote
Old 01-04-2005, 04:03 PM   #2
John Saunders
 
Posts: n/a
Default Re: finding repeateritem which matches a fieldvalue
"louise raisbeck" <> wrote in
message news:742272C7-6AB2-4CEF-9597-...
> Hi there, I have a brain block on finding a repeater item which matches a
> field from the row of the datasource. If my datasource has a column called
> 'somethingid' i want to find the repeateritem which has somethingid=1
> (there
> will only be one)
>
> so I have set up an iterator
>
> foreach (RepeaterItem item in myrepeater.Items)
> {
> //below is what i am trying to do but this doesnt work, not sure of syntax
> if (item.dataitem["somethingid"]=="1") {
>
> do something
>
> }
> }
>
> Not sure what syntax to use. I'm sure its pretty simple. Thank you.


Most pages do something like this:

private void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// Load data from the database
Page.DataBind();
}
}

In this case, RepeaterItem.DataItem will only be available during the
DataBind. In particular, it will not be available on PostBacks.

You'll have to create your own mechanism for associating database rows with
the ItemIndex of the RepeaterItem.

John Saunders





John Saunders
  Reply With Quote
Old 01-04-2005, 04:15 PM   #3
Eliyahu Goldin
 
Posts: n/a
Default Re: finding repeateritem which matches a fieldvalue
Repeater item is built from a template. It can be anything. It doesn't have
any properties for datasource. You need to know exactly what element in the
item template your column value lands on and navigate to that element.

Eliyahu

"louise raisbeck" <> wrote in
message news:742272C7-6AB2-4CEF-9597-...
> Hi there, I have a brain block on finding a repeater item which matches a
> field from the row of the datasource. If my datasource has a column called
> 'somethingid' i want to find the repeateritem which has somethingid=1

(there
> will only be one)
>
> so I have set up an iterator
>
> foreach (RepeaterItem item in myrepeater.Items)
> {
> //below is what i am trying to do but this doesnt work, not sure of syntax
> if (item.dataitem["somethingid"]=="1") {
>
> do something
>
> }
> }
>
> Not sure what syntax to use. I'm sure its pretty simple. Thank you.





Eliyahu Goldin
  Reply With Quote
Old 01-04-2005, 04:51 PM   #4
=?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=
 
Posts: n/a
Default RE: finding repeateritem which matches a fieldvalue
Plan B then. ok guys thanks.

"louise raisbeck" wrote:

> Hi there, I have a brain block on finding a repeater item which matches a
> field from the row of the datasource. If my datasource has a column called
> 'somethingid' i want to find the repeateritem which has somethingid=1 (there
> will only be one)
>
> so I have set up an iterator
>
> foreach (RepeaterItem item in myrepeater.Items)
> {
> //below is what i am trying to do but this doesnt work, not sure of syntax
> if (item.dataitem["somethingid"]=="1") {
>
> do something
>
> }
> }
>
> Not sure what syntax to use. I'm sure its pretty simple. Thank you.



=?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
DVD Verdict reviews: OCEAN'S TWELVE, HOTEL RWANDA, FINDING NEVERLAND, and more! DVD Verdict DVD Video 1 04-25-2005 10:30 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46