473,395 Members | 1,578 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,395 software developers and data experts.

Binding to a Repeater in Codebehind...a little confusion.

Why doesn't the casting of "e.Item.DataI*tem" as a "DataRow" (or even
a "DataRowView" as in other online examples) work? I would love to get
this type of code to work with my code that uses a Label for building a
URL instead of the RadioButtonList as in the example snippet below. I
know how to implement this with a Label but I end up having to do
something like this:

myLabel.Text = (string) DataBinder.Eval(e.Item.DataItem, "Info");

instead of something much cleaner, logical looking, and desirable (to
me) like this:

myLabel.Text = (string) ((DataRow)e.Item.DataI*tem)["Info"];

Also, the thought of "DataBinder.Eval" just seems to partially negate
moving this to the codebehind.

-

Here is an example snippet from this newsgroup that I found that
doesn't work either...and it give the same "cast" error on casting as
"DataRow".

<asp:repeater id="rptEstimates" runat="server"
ItemDataBound="DataBoundItem>
....
<script runat="server">
void DataBoundItem(Object Sender, RepeaterItemEventArgs e) {
// This event is raised for the header, the footer,
separators,
and items.
// Execute the following logic for Items and Alternating
Items.
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType
==
ListItemType.AlternatingItem) {
RadioButtonList rbl =
(RadioButtonList)e.Item.FindCo*ntrol("rptEstimates ");
if ( rbl != null )
{
rbl.SelectedValue =
(string)((DataRow)e.Item.DataI*tem)["BidResponse"];
}
}
}

-

Is there a problem with Framework version maybe?

Nov 19 '05 #1
2 2155
More I look into this the more confusing it gets. I think I am too
close to the subject matter at the moment.

Nov 19 '05 #2

no****@somewhere.com wrote:
More I look into this the more confusing it gets. I think I am too
close to the subject matter at the moment.

I went ahead and created my own custom web control. I could have made
modifications at the dataset level before the bind but with this
situation, it was a better fit to build a new control.

Thanks (for nuttin' ;-)

Nov 19 '05 #3

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

Similar topics

3
by: francois | last post by:
Hi, I have a little problem I am using a stored procedure to retrieve my date. What I want to achieve is to be able to "skip" some row from the resultset i retrieve back from the stored...
0
by: T-Bone | last post by:
Problem with page_load firing twice was driving me mad. I had an aspx page with several webusercontrols in it. One of them had a repeater with some databinders in it. In my codebehing I bind a...
2
by: Gastin | last post by:
I am consuming a web serivce from Amazon.Com. I have the following class which was autogenerated by VS.NET when I created a Web Reference to...
8
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: ...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
4
by: Brad Baker | last post by:
I'm going a little crazy :) I'm trying to bind a repeater control to a dataset on page load using the following code: if (Request.QueryString != null) { string customerid = Request.QueryString;...
5
by: DotNetNewbie | last post by:
Hi, It is not possible to bind a Generic.List collection to a repeater I guess huh? I am getting this error: An invalid data source is being used for rpCategories. A valid data source must...
12
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I'm doing a web app in VB/Dot Net 2.0. I'm probably a bit rusty and I have no experience using the repeater control. I have a user control I've created with multiple properties. I've created a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.