最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
在datagrid里面的事件itemCreat以及相关联的控件事件
时间:2022-06-30 10:27:57 编辑:袖梨 来源:一聚教程网
//创建句柄委托
private void dgOrderConfirm_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
CheckBox cb=(CheckBox)e.Item.FindControl("cbselect");
cb.CheckedChanged+=new System.EventHandler(this.cbselectChanged);
}
}
//创建事件
private void cbselectChanged(object sender,System.EventArgs e)
{
CheckBox cb=(CheckBox)sender; DataGridItem li=(DataGridItem)cb.Parent.Parent;
if(cb.Checked==true)
{
li.Cells[8].Text=string.Format("{0:F2}",float.Parse(li.Cells[7].Text)*(float.Parse(((TextBox)li.FindControl("tbdiscount")).Text))).ToString();
this.lbgetsum.Text=string.Format("{0:F2}",(float.Parse(this.lbgetsum.Text)+float.Parse(li.Cells[8].Text))).ToString();
}
else
{
this.lbgetsum.Text=string.Format("{0:F2}",(float.Parse(this.lbgetsum.Text)-float.Parse(li.Cells[8].Text))).ToString();
li.Cells[8].Text="";
}
}
//遍历datagrid
foreach(DataGridItem dgi in DataGrid1.Items)
{
if(((CheckBox)dgi.FindControl("cbselect")).Checked && (((CheckBox)dgi.FindControl("cbback")).Checked))
{
Response.Write(string.Format(""));
return;
}
}
private void dgOrderConfirm_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
CheckBox cb=(CheckBox)e.Item.FindControl("cbselect");
cb.CheckedChanged+=new System.EventHandler(this.cbselectChanged);
}
}
//创建事件
private void cbselectChanged(object sender,System.EventArgs e)
{
CheckBox cb=(CheckBox)sender; DataGridItem li=(DataGridItem)cb.Parent.Parent;
if(cb.Checked==true)
{
li.Cells[8].Text=string.Format("{0:F2}",float.Parse(li.Cells[7].Text)*(float.Parse(((TextBox)li.FindControl("tbdiscount")).Text))).ToString();
this.lbgetsum.Text=string.Format("{0:F2}",(float.Parse(this.lbgetsum.Text)+float.Parse(li.Cells[8].Text))).ToString();
}
else
{
this.lbgetsum.Text=string.Format("{0:F2}",(float.Parse(this.lbgetsum.Text)-float.Parse(li.Cells[8].Text))).ToString();
li.Cells[8].Text="";
}
}
//遍历datagrid
foreach(DataGridItem dgi in DataGrid1.Items)
{
if(((CheckBox)dgi.FindControl("cbselect")).Checked && (((CheckBox)dgi.FindControl("cbback")).Checked))
{
Response.Write(string.Format(""));
return;
}
}
相关文章
- boss智能门锁如何设置密码 04-29
- 王者荣耀世界橘右京厉害吗 04-29
- 《青云劫攻略天赋技能,成就无敌仙侠》(解锁潜能,掌握绝学,成就仙侠传奇) 04-29
- 桃源深处有人家藏经室悟证一至七日通关答案 04-29
- 怎么击败《Saros》中的“破碎崛起”先知 Boss 04-29
- 宫小攻略技能推荐2023(玩转宫小,轻松游戏攻略指南) 04-29