using system;
using system.data;
using system.configuration;
using system.collections;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.web.ui.htmlcontrols;
using system.collections.generic;
using disdatedal;
using system.data.sqlclient;
public partial class zldxmx : system.web.ui.page
///
/// 動態新增gridview
///
///
///
public void addgridview(ilistlist7036, int count, string day,ilistlisttype)
for (int j=0;jgv.rowdatabound += new gridviewroweventhandler(gv_rowdatabound);
gv.databind();
//**名稱及**
label lblsname = new label();
lblsname.font.size = 10;
lblsname.height = 20;
lblsname.attributes.add("runat", "server");
lblsname.text = "**名稱(**):" + list7036[0].sname.tostring() + "(" + list7036[0].smybol.tostring() + ")";
this.placeholder.controls.add(lblsname);
label lblf0010 = new label();
lblf0010.font.size = 10;
lblf0010.height = 20;
if (list7036[0].f0010 > 0)
else
this.placeholder.controls.add(lblf0010);
label lblf0110 = new label();
lblf0110.font.size = 10;
lblf0110.height = 20;
lblf0110.text = "" + day + "日成交金額(萬元)*:" + list7036[0].f0020.tostring() + "
";this.placeholder.controls.add(lblf0110);
//給動態新增的gridview 前新增乙個lable用於顯示異動說明
ilistlistyidong = new list();
label lblshuoming = new label();
lblshuoming.width = 903;
lblshuoming.height = 15;
lblshuoming.font.size = 10;
lblshuoming.backcolor = system.drawing.color.fromname("#b5af94");
lblshuoming.text = "異動說明: ";
if (listtype.count > 1)
else
lblshuoming.text += listtype[j].tostring() + "/";}}
else
lblshuoming.text += listtype[0].tostring() + "";
this.placeholder.controls.add(lblshuoming);
this.placeholder.controls.add(gv);
label a = new label();
a.height = 12;
a.width = 903;
this.placeholder.controls.add(a);
this.lblcurrenttime.text = ******dateformate(list7036[0].tdate.tostring());//當前時間
}public string ******dateformate(string date)
void gv_rowdatabound(object sender, gridviewroweventargs e)
///
/// 樣板類產生器,以建立樣板字段
///
public class gridviewtemplate : itemplate
//實現了itemplate介面的方法
public void instantiatein(system.web.ui.control container)
void lblxu_databinding(object sender, eventargs e)
}void lblinm_databinding(object sender, eventargs e)
}void lblxingzhi_databinding(object sender, eventargs e)
//樣板的databind
private void lblsname_databinding(object sender, eventargs e)
}///
/// 獲得7035 表中所有的資料
///
public void bind(string time, string symbol)
string sql2 = "select top 100* from (select top 1000 convert(varchar(10),tdate,120) as tdate,symbol,sname,type,round(f0010,2) as f0010,f0020,f0030,f0040,f0050,f0060,round(f0070/10000,2) as f0070,round(f0080/10000,2) as f0080,f0090,round(f0100,2) as f0100,round(f0110/10000,2) as f0110,round(f0120/10000,2) as f0120,round(f0130,2) as f0130,status,id from tb_7035 a where symbol='" + symbol + "' and tdate='" + time + "' and type in (select top 1 type from tb_7036 where symbol='" + symbol + "' and tdate='" + time + "' and f0050='" + dr[0].tostring() + "') and f0040='**'order by f0040 asc,f0070 desc) aa union all select top 100* from (select top 1000 convert(varchar(10),tdate,120) as tdate,symbol,sname,type,round(f0010,2) as f0010,f0020,f0030,f0040,f0050,f0060,round(f0070/10000,2) as f0070,round(f0080/10000,2) as f0080,f0090,round(f0100,2) as f0100,round(f0110/10000,2) as f0110,round(f0120/10000,2) as f0120,round(f0130,2) as f0130,status,id from tb_7035 a where symbol='" + symbol + "' and tdate='" + time + "' and type in (select top 1 type from tb_7036 where symbol='" + symbol + "' and tdate='" + time + "' and f0050='" + dr[0].tostring() + "') and f0040='賣出'order by f0040 asc,f0080 desc) aa";
addgridview(get7036data(sql2), count, dr[0].tostring(), listtype);}}
}///
/// 根據sql 語句返回乙個集合
///
///
///
public ilistget7036data(string sql)
list7036.add(tb7036);
}return list7036;
}
GridView動態新增模板列
gridview動態新增模板列 這個case 經常會遇到,網上相關資料也不少,但是關於如何動態為新增在模板列中的控制項新增事件卻沒有。本文就是為解決這種情況而寫。如下 gridviewtemplatedemo.aspx xhtml view plain copy page language c au...
gridview手寫繫結
using system using system.collections.generic using system.linq using system.web using system.web.ui using system.web.ui.webcontrols using comp.model ...
jquery動態新增繫結事件
場景 在使用jquery的方式為元素繫結事件時,我經常使用bind或者click,但這只能為頁面已經載入好的元素繫結事件。像需要用ajax的方式請求遠端資料來動態新增頁面元素時,顯然以上幾種繫結事件的方式是無效的。解決方案 1.7之後也就是1.8開始,就不推薦用live 官方推薦用on 又稱事件委託...