如何使用绑定字段在动态网格中编写按钮单击事件

如何使用绑定字段在动态网格中编写按钮单击事件

本文介绍了如何使用绑定字段在动态网格中编写按钮单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 DataTable dtdcDetails =  new  DataTable(); 
objRetailPL.sno = Convert.ToInt32(dtdate.Rows [i] [ sno ]的ToString());
dtdcDetails = objRetailBAL.dtdateTallyTable(objRetailPL);

GridView gv = new GridView();
// gv.ID =gv+ dtdate.Rows [i] [BranchDate]。 ToString();
gv.Width = 600 ;
标签lblTotal = 标签();
Label lbltotaleggs = new Label();

BoundField partyname = new BoundField();
partyname.HeaderText = PartyName;
partyname.DataField = partyname;
gv.Columns.Add(partyname);

BoundField birdtype = new BoundField();
birdtype.HeaderText = 鸟类;
birdtype.DataField = birdname;
gv.Columns.Add(birdtype);

BoundField totweight = new BoundField();
totweight.HeaderText = 总重量;
totweight.DataField = totalweight;
gv.Columns.Add(totweight);

BoundField rateperkg = new BoundField();
rateperkg.HeaderText = Rate / Kg;
rateperkg.DataField = rateperkg;
gv.Columns.Add(rateperkg);


BoundField Bdcno = new BoundField();
Bdcno.HeaderText = DCNo;
Bdcno.DataField = dcno;
gv.Columns.Add(Bdcno);


ButtonField btn = new ButtonField();
// 初始化DataField值。
btn.ItemStyle.Horizo​​ntalAlign = Horizo​​ntalAlign 。中央;
btn.CommandName = 按钮;
btn.ButtonType = ButtonType.Button;
btn.Text = 确认;
btn.Visible = true ;
gv.Columns.Add(btn);



gv.AutoGenerateColumns = false ;
gv.ShowFooter = true ;
gv.DataSource = dtdcDetails;
gv.DataBind();
解决方案



DataTable dtdcDetails = new DataTable();
objRetailPL.sno = Convert.ToInt32(dtdate.Rows[i]["sno"].ToString());
dtdcDetails = objRetailBAL.dtdateTallyTable(objRetailPL);

GridView gv = new GridView();
//gv.ID = "gv" + dtdate.Rows[i]["BranchDate"].ToString();
gv.Width = 600;
Label lblTotal = new Label();
Label lbltotaleggs = new Label();

BoundField partyname = new BoundField();
partyname.HeaderText = "PartyName";
partyname.DataField = "partyname";
gv.Columns.Add(partyname);

BoundField birdtype = new BoundField();
birdtype.HeaderText = "Bird Type";
birdtype.DataField = "birdname";
gv.Columns.Add(birdtype);

BoundField totweight = new BoundField();
totweight.HeaderText = "Total Weight";
totweight.DataField = "totalweight";
gv.Columns.Add(totweight);

BoundField rateperkg = new BoundField();
rateperkg.HeaderText = "Rate/Kg";
rateperkg.DataField = "rateperkg";
gv.Columns.Add(rateperkg);


BoundField Bdcno = new BoundField();
Bdcno.HeaderText = "DCNo";
Bdcno.DataField = "dcno";
gv.Columns.Add(Bdcno);


ButtonField btn = new ButtonField();
//Initalize the DataField value.
btn.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
btn.CommandName = "Button";
btn.ButtonType = ButtonType.Button;
btn.Text = "Confirm";
btn.Visible = true;
gv.Columns.Add(btn);



gv.AutoGenerateColumns = false;
gv.ShowFooter = true;
gv.DataSource = dtdcDetails;
gv.DataBind();
解决方案



这篇关于如何使用绑定字段在动态网格中编写按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 02:50