}
elseif(e.Item.ItemType==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='#c8dafa'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='#f6f6f6'");
}
}
10.为DataGrid控件添加接钮处理事件程序
在DataGrid控件标签中加入如下代码
OnItemCommand="ItemsGrid_Command"
在后台中加入如下代码
publicvoidItemsGrid_Command(Objectsender,DataGridCommandEventArgse)
{
switch(((LinkButton)e.CommandSource).CommandName)
{
case"Delete":
intclassID=Int32.Parse((e.Item.Cells[0].Text).ToString());
ActorClass.DeleteActorClass(classID);
if(Request.QueryString.Get("classID")!=null)
Common.BindData(DataGrid1,Common.GetSource("select*fromActorClasswhereparentID="+Request.QueryString.Get("classID")+"orderbydepth,orderIDdesc"));
else
Common.BindData(DataGrid1,Common.GetSource("select*fromActorClasswheredepth=1orderbydepth,orderIDdesc"));
break;
//Addothercaseshere,iftherearemultipleButtonColumnsin
//theDataGridcontrol.
case"hidden":
intactorID=Int32.Parse((e.Item.Cells[0].Text).ToString());
ActorClass.HiddenActorClass(actorID);
if(Request.QueryString.Get("classID")!=null)
Common.BindData(DataGrid1,Common.GetSource("select*fromActorClasswhereparentID="+Request.QueryString.Get("classID")+"orderbydepth,orderIDdesc"));
else
Common.BindData(DataGrid1,Common.GetSource("select*fromActorClasswheredepth=1orderbydepth,orderIDdesc"));
break;
case"MoveUp":
intactorclassID=Int32.Parse((e.Item.Cells[0].Text).ToString());
stringorderID=(e.Item.Cells.Text).ToString();
ActorClass.MoveUp(orderID,actorclassID);
if(Request.QueryString.Get("classID")!=null)
Common.BindData(DataGrid1,Common.GetSource("select*fromActorClasswhereparentID="+Request.QueryString.Get("classID")+"orderbydepth,orderIDdesc"));
else
Common.BindData(DataGrid1,Common.GetSource("select*fromActorClasswheredepth=1orderbydepth,orderIDdesc"));
break;
case"MoveDown":
actorclassID=Int32.Parse((e.Item.Cells[0].Text).ToString());
orderID=(e.Item.Cells.Text).ToString();
ActorClass.MoveDown(orderID,actorclassID);
if(Request.QueryString.Get("classID")!=null)
Common.BindData(DataGrid1,Common.GetSource("select*fromActorClasswhereparentID="+Request.QueryString.Get("classID")+"orderbydepth,orderIDdesc"));
else
Common.BindData(DataGrid1,Common.GetSource("select*fromActorClasswheredepth=1orderbyorderID"));
break;
[8] [9] [10]
