最新下载
热门教程
- 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;
}
}
相关文章
- 多邻国官网登录入口-Duolingo官方网页版入口 01-18
- 啥都能看的视频神器-资源最全的视频神器 01-18
- 新浪微博网页版手机端-新浪微博手机版网页入口 01-18
- 夸克网页版-夸克浏览器网页版入口 01-18
- 动漫共和国入口_动漫共和国官网与分类导航 01-18
- 绝世唐门漫画完整免费入口在哪?2026最新免费观看地址及平台汇总 01-18