日期:2014-05-20  浏览次数:20521 次

关于DATAGRID
<asp:DataGrid   ID= "DataGrid1 "   runat= "server "   OnItemCommand= "DeleteEnumerate ">
      <Columns>
          <asp:ButtonColumn   CommandName= "Delete "   Text= "删除 "   ButtonType= "PushButton "> </asp:ButtonColumn>
        </Columns>                                                
</asp:DataGrid> 怎样使ButtonColumn相应函数啊
有没有相关的资料

------解决方案--------------------
先设置按钮的Commandname属性,然后在ItemCommand事件里,用e对象去获得当前行
/// <summary>
/// 点击 "开始查评 ", "查评 ", "结束 "等
/// </summary>
private void DtgEvalItem_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName == "Close ")
{
int ProjectTaskID = Convert.ToInt32(DtgEvalItem.DataKeys[e.Item.ItemIndex].ToString());
Business.ProjectTask NewTask = new Siwei.SES.Business.ProjectTask(ProjectTaskID);
NewTask.status = "查评完毕 ";
NewTask.FinishedDate = DateTime.Now.Date;
NewTask.Save();
//如查评结束后,此任务没发现任何问题,则自动评为满分
Business.Problem NewProblem = new Siwei.SES.Business.Problem();
DataSet ds = NewProblem.RetrieveProblem(ProjectTaskID);
if(ds.Tables[0].Rows.Count == 0)
{
Business.EvalItem NewItem = new Siwei.SES.Business.EvalItem();
DataRow dr = NewItem.EvalItemStandardPoint(ProjectTaskID);
Business.Grade NewGrade = new Siwei.SES.Business.Grade();
NewGrade.ProjectTaskID = ProjectTaskID;
DataSet dsGrade = NewGrade.RetrieveTaskD();
if(dsGrade.Tables[0].Rows.Count == 0)
{
NewGrade.DeductPointID = -1;
NewGrade.StandardPoint = Convert.ToInt32(dr[ "STANDARDPOINT "].ToString());
NewGrade.LostPoint = 0;
NewGrade.GainPoint = Convert.ToInt32(dr[ "STANDARDPOINT "].ToString());
NewGrade.GainPercent = 100;
NewGrade.ProjectTaskID = ProjectTaskID;
NewGrade.Save();
}
else
{
NewGrade.DeductPointID = Convert.ToInt32(ds.Tables[0].Rows[0][ "DEDUCTPOINTID "].ToString());
NewGrade.StandardPoint = Convert.ToInt32(dr[ "STANDARDPOINT "].ToString());
NewGrade.LostPoint = 0;
NewGrade.GainPoint = Convert.ToInt32(dr[ "STANDARDPOINT "].ToString());
NewGrade.GainPercent = 100;
NewGrade.ProjectTaskID = ProjectTaskID;
NewGrade.Save();
}
}
GotoHomePage();
}
}