日期:2014-05-18 浏览次数:20539 次
protected void RPTNewsClass_ItemCommand(object source, RepeaterCommandEventArgs e) { var result =new OperationResult<NewsClass>();//我自己的逻辑组件 不用管 if (e.CommandName == "Edit")//判断哪个按钮处罚的 { result= this.Edit(e); } if (result.IsSuccess) { Utility.Alert(this.Page, "操作成功!"); } else { Utility.Alert(this.Page, "操作失败!"); } } private OperationResult<NewsClass> Edit(RepeaterCommandEventArgs e) { var service = ObjectFactory.GetInstance<NewsClassService>(); var tbName = e.Item.FindControl("TBName") as TextBox;//通过这句找控件 var ddlRootClass = e.Item.FindControl("DDLClass") as DropDownList; var entity = new NewsClass() { Class_name = tbName.Text, Class_belongto = Convert.ToInt32(ddlRootClass.SelectedValue), Class_id = Convert.ToInt32(e.CommandArgument) }; return service.Update(entity); }
------解决方案--------------------
主要是FindControl("txtSortID")这个方法
几个主要的数据绑定控件都差不多这样
------解决方案--------------------
(Item.FindControl("ControlId") as controlType)...
去网上搜搜多的很
------解决方案--------------------
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "UP")
{
//上移
}
else if (e.CommandName == "DOWN")
{
//下移
}
else if (e.CommandName == "DEL")
{
//删除
}
}