私はリピーターを持っており、その内部でいくつかのユーザーコントロールをパネルにバインドしています。パネルにはOnClick
イベントがあり、ItemCommand
. DataItem
ポストバック全体で保持されないため、イベント中に null になることを認識していItemCommand
ます。私の要件は、特定のユーザーコントロールがクリックされたときに (Javascript を使用せずに) 色を変更することです。誰にもアイデアがありますか?
1 に答える
0
以下のように、itemDataBound イベントで特定の usercontrols onClick のクラス名を変更してみてください。
protected void DataList1_ItemDataBound(object sender,
DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
//Add eventhandlers for highlighting
//a DataListItem when the mouse hovers over it.
e.Item.Attributes.Add("onmouseover",
"this.oldClass = this.className;" +
" this.className = 'EntryLineHover'");
e.Item.Attributes.Add("onmouseout",
"this.className = this.oldClass;");
//Add eventhandler for simulating
//a click on the 'SelectButton'
e.Item.Attributes.Add("onclick",
this.Page.ClientScript.GetPostBackEventReference(
e.Item.Controls[1], string.Empty));
}
}
于 2012-11-27T05:02:10.347 に答える