Grabbing a value for current row in ItemDataBound of Repeater

I get a null exception when trying to access a value for the current boundrow in my repeater.  I'm probably just  missing something here?

 

    public void rptSearchStrings_DataBound(Object sender, RepeaterItemEventArgs e)
    {
 

    public void rptPartStrings_DataBound(Object sender, RepeaterItemEventArgs e)
    {
        DataRowView dv = e.Item.DataItem as DataRowView;
        string partString = ((DataRowView)e.Item.DataItem).Row["partstring"].ToString();

....

 dv is null

....

 dv is null
LVL 1
dba123Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anurag ThakurTechnical ManagerCommented:
try to cast it as a datarow
the sample from msdn is for a object data source but you are nearly there - you dv is null because i think its a row and not a view
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.itemdatabound.aspx

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dba123Author Commented:
I'm still not finding the right way to access the current row and a specific value in the row's columns.
sm394Commented:
try that
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{

DataRowView dv = e.Item.DataItem as DataRowView;
string partString = ((DataRowView)e.Item.DataItem).Row["partstring"].ToString();

}
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

dba123Author Commented:
sm394, I don't see how yours is different from what I just posted originally.
dba123Author Commented:
I put that check in for item or alternating item, and it makes no difference
dba123Author Commented:
figured it out.  You can just case the e.Data.Item to the orignal object type and use that type directly

(Product)e.Item.DataItem

then

Product.PropertyName (or column name really)
Anurag ThakurTechnical ManagerCommented:
thats what my link suggested if you might have had a look deeply
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.