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

Casting repeater DataItem

Is it possible to cast the DataItem of the repeater control to a typed
datatable? I'm trying to use the following code to do this and it
doesn't work.

This code always throws an invalid cast exception.

private void frameRepeater_ItemCreated(object sender,
RepeaterItemEventArgs e)
{
FramesRow frame = e.Item.DataItem as FramesRow;
int frameID = 0;
if ( frame != null )
frameID = frame.FrameID;
}

Now if I try the following code it does work, but I can't use my
strongly typed database anymore.

private void frameRepeater_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
if ( e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType
== ListItemType.Item )
{
DataRowView frame = e.Item.DataItem as DataRowView;

int frameID = 0;

if ( frame != null )
frameID = (int)frame["FrameID"];

DropDownList frameSize = (DropDownList)e.Item.FindControl("frameSize");
frameSize.DataValueField = "FrameSizeID";
frameSize.DataTextField = "FrameSize";
frameSize.DataSource =
ServiceFactory.GetProductManager().GetFrameModelSi zesTest( frameID );
frameSize.DataBind();

DropDownList frameColor = (DropDownList)e.Item.FindControl("frameColor");
frameColor.DataValueField = "FrameColorID";
frameColor.DataTextField = "Color";
frameColor.DataSource =
ServiceFactory.GetProductManager().GetFrameModelCo lorsTest( frameID );
frameColor.DataBind();
}
}

regards,

Aaron
Nov 19 '05 #1
0 1746

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

Similar topics

8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
1
by: Christiaan Nieuwlaat | last post by:
Hi everyone, Could you please help me with this? I need to create a table in which resultdata from a sql server table can be shown and/or edited by using controls, for instance the radiobutton....
1
by: fredda054 | last post by:
Hi everybody ! With help from some nice people here I'm getting close to solve my problem with dbnull values in a repeater. I got it pretty much done, I just ned to fix some syntax. I get a...
1
by: jeremystein | last post by:
With nested repeaters, how can I access the outer repeater's DataItem from the inner repeater? Here's a snippet from my aspx: <asp:repeater id="OuterRepeater" runat="server"...
2
by: GD | last post by:
I'd like to use a Repeater to display data coming back from a cross-tab report. Because it's a cross-tab, I generally don't know how many columns are coming back. They do follow a certain format: ...
3
by: renil | last post by:
I have a repeater control that displays info. from a datatable. Each row in the repeater has a checkbox. Also, I have a delete linkbutton outside the repeater control. What I'm trying to do when...
0
by: erin.sebastian | last post by:
Hello All, I have created a web page. At the top of the page there are 4 links; upon clicking on one of the links it brings up the left hand side menu, it's a repeater that loops through items...
0
by: uncensored | last post by:
Hello everyone, I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me...
1
by: Doogie | last post by:
Hi, I have been trying to get a checkbox added to a repeater control of mine and then try to access events of the repeater control when a user clicks the checkbox. At first, since the control is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.