![]() |
|
|
|||||||
![]() |
ASP Net - finding repeateritem which matches a fieldvalue |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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?= |
|
|
|
|
#2 |
|
Posts: n/a
|
"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 |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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?= |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |