473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.
Nov 19 '05 #1
3 1537
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:74**********************************@microsof t.com...
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

Nov 19 '05 #2
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" <lo************@discussions.microsoft.com> wrote in
message news:74**********************************@microsof t.com...
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.

Nov 19 '05 #3
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.

Nov 19 '05 #4

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

Similar topics

8
by: Eric Linders | last post by:
Hi, I'm trying to figure out the most efficient method for taking the first character in a string (which will be a number), and use it as a variable to check to see if the other numbers in the...
1
by: Tristan | last post by:
Im trying to expand a search util by uing regular expression to allow common search criteria such as +-* and phrases "". My understanding of ereg(string pattern, string string, ) is that the...
3
by: DonRex | last post by:
Hello all! I couldn't find a web application-newsgroup for ASP.NET, so I'm sorry if this is the wrong forum! Synopsis: In my webform I have 3 nested repeaters: rpWeeks ----- rpTime
1
by: Peter Rilling | last post by:
In the Repeater.ItemCreated handler, I am hooking the RepeaterItem.PreRender method. This event fires when the RepeaterItem is being rendered, the problem is that I want access to the DataItem...
2
by: duende | last post by:
I was hoping someone will be able to help me, i've got a bit of experience with mysql, but nothing quite like this. I have a table with 3 columns 'sid', 'aid', and 'call'. What i want to do is...
1
by: psmahesh | last post by:
Hi folks, I am comparing two arrays and removing matches from the second array from the first array. Can someone take a look at this code below and mention if this is okay and perhaps if there...
7
by: Brad Baker | last post by:
I am trying to programmatically set a placeholder control in csharp which is nested inside a repeater control between <ItemTemplateand </ItemTemplate> tags, however I am running into problems. I've...
4
by: Hardik Dangar | last post by:
hi friends, i have a bunch of html pages and i want to fetch records from them and i m really confused how i can do after working with regular expressions and other stuffs from last few days can...
0
by: wilkinsonr | last post by:
Hi All, I'm having a metal blank. This is my class: public class MyRepeaterItem : System.Web.UI.WebControls.RepeaterItem { public MyRepeaterItem(int itemIndex, ListItemType itemType) :...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.