dba123
asked on
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(O bject sender, RepeaterItemEventArgs e)
{
DataRowView dv = e.Item.DataItem as DataRowView;
string partString = ((DataRowView)e.Item.DataI tem).Row[" partstring "].ToStrin g();
....
dv is null
....
dv is null
public void rptSearchStrings_DataBound
{
public void rptPartStrings_DataBound(O
{
DataRowView dv = e.Item.DataItem as DataRowView;
string partString = ((DataRowView)e.Item.DataI
....
dv is null
....
dv is null
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try that
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingIt em)
{
DataRowView dv = e.Item.DataItem as DataRowView;
string partString = ((DataRowView)e.Item.DataI tem).Row[" partstring "].ToStrin g();
}
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingIt
{
DataRowView dv = e.Item.DataItem as DataRowView;
string partString = ((DataRowView)e.Item.DataI
}
ASKER
sm394, I don't see how yours is different from what I just posted originally.
ASKER
I put that check in for item or alternating item, and it makes no difference
ASKER
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)
(Product)e.Item.DataItem
then
Product.PropertyName (or column name really)
thats what my link suggested if you might have had a look deeply
ASKER