怎么再datalist事件ItemDataBound或者是ItemCreated时 FindControl不出控件

2024-12-02 02:31:58
推荐回答(4个)
回答1:

void Item_Created(Object sender, DataListItemEventArgs e)
{

if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{

// Retrieve the Label control in the current DataListItem.
Label PriceLabel = (Label)e.Item.FindControl("PriceLabel");

// Retrieve the text of the CurrencyColumn from the DataListItem
// and convert the value to a Double.
Double Price = Convert.ToDouble(
((DataRowView)e.Item.DataItem).Row.ItemArray[2].ToString());

// Format the value as currency and redisplay it in the DataList.
PriceLabel.Text = Price.ToString("c");

}

}
OnItemDataBound类似

回答2:

应该可以找到的,看看你的方法是否正确

回答3:

item.findcontrol

回答4:

不太明白你的意思