上一篇 | 下一篇

DataGrid使用心得(附大量代码)

发布: 2008-6-26 22:34 | 作者: admin | 来源: | 查看: 12次

}

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]

字号: | 推荐给好友

评分:0

我来说两句