~~~~如何在DataGrid模板中动态添加一个文本框~~~~请高手赐教~~~~~谢谢~~~~~
解决方案 »
- 多张数据表拼接问题
- 关于File.GetFiles()的文件操作问题
- winform响应方向键的急问题~~
- 请教1:相同作用域的关于静态只读变量与常量有什么区别呢?
- 还是c#调用打印机的问题 有数据 有实例
- 怎樣可以將Assembly中的東西還原出來?我的意思是將Assemly中的Flash還原爲swf文件。目前是資源。
- INI文件写入的问题
- 一个困绕了一个多月的难题,寻求解决方案……
- winform 中 A窗体有一个DataTable,A窗体跳转B窗体,再跳转A,现在A中DataTable中的值不能清空
- C#解析XML文件遇到一个节点下有多个相同子节点的情况,只是数据不一样
- 200分求一个好的c#语言开发的开源的erp系统,哪位有的,给我一个!谢谢!
- 网页可以局部刷新吗?
private void BindData()
{
try
{
this.tr_blink.Visible = true;
this.tr_detail.Visible = false; DataTable detailInfo = null; // Not Found in Sessoin
// We research the result
if( this.Session["dsp_EnqTransFares_Head"] == null || this.Session["dsp_EnqTransFares_Detail"] == null )
{
// First intialize the page
if( this.hid_SelectValue.Value == string.Empty )
{
return;
}
else
{
EnqTransFaresDB fareDB = new EnqTransFaresDB( this.UserInfo.LangCode );
detailInfo = fareDB.GetFareInfo( this.hid_SelectValue.Value , this.UserInfo.CompCode , DateTime.Parse(hid_EffiveDate.Value) );
this.Session["dsp_EnqTransFares_Detail"] = detailInfo;
}
}
else
{
detailInfo = (DataTable)this.Session["dsp_EnqTransFares_Detail"];
} detailInfo.DefaultView.Sort = this.hid_SortField.Value + this.hid_SortType.Value;
DataView detailView = detailInfo.DefaultView; this.dg_FareHead.DataSource = detailView;
this.dg_FareHead.DataBind(); // Build DataGrid Dynamically
// Remove All existed Columns
while( this.dg_FareDetail.Columns.Count != 0 )
{
this.dg_FareDetail.Columns.RemoveAt(0);
} // Add columns according to the dateSource
// start from NO.1 , skip the first column (Destination)
for( int i = 1 ; i < detailInfo.Columns.Count ; i ++ )
{
BoundColumn column = new BoundColumn(); column.DataField = detailInfo.Columns[i].ColumnName;
column.HeaderText = detailInfo.Columns[i].ColumnName;
column.SortExpression = detailInfo.Columns[i].ColumnName;
column.DataFormatString = "{0:n2}"; column.HeaderStyle.Wrap = false;
column.HeaderStyle.Font.Underline = true;
column.ItemStyle.HorizontalAlign = HorizontalAlign.Right; dg_FareDetail.Columns.Add(column);
} dg_FareDetail.DataSource = detailInfo;
dg_FareDetail.DataBind(); // Reset DataGrid Color
foreach( DataGridItem dgi in dg_FareDetail.Items )
{
for( int i = 0 ; i < dgi.Cells.Count ; i ++ )
{
// start from NO.1 , skip the first column (Destination)
if( detailView[dgi.ItemIndex][i+1].ToString() == string.Empty )
{
// Using Grey Color
dgi.Cells[i].BackColor = Color.FromArgb(221,221,221);
}
}
} this.tr_blink.Visible = false;
this.tr_detail.Visible = true;
}
catch( ApplicationException ex )
{
ComLogOutput.WriteLogFile(ex);
this.lbl_Err.Text = ex.Message;
}
catch( Exception ex )
{
ComLogOutput.WriteLogFile(ex);
}
}
<EDITITEMSTYLE HORIZONTALALIGN="Center" CSSCLASS="Result_DG_EditItemStyle"></EDITITEMSTYLE>
<ALTERNATINGITEMSTYLE HORIZONTALALIGN="Center" CSSCLASS="Result_DG_AlternatingItemStyle"></ALTERNATINGITEMSTYLE>
<ITEMSTYLE HORIZONTALALIGN="Center" CSSCLASS="Result_DG_ItemStyle" Wrap="False"></ITEMSTYLE>
<HEADERSTYLE HORIZONTALALIGN="Center" CSSCLASS="Result_DG_HeaderStyle" Wrap="False"></HEADERSTYLE>
<Columns>
</Columns>
</ASP:DATAGRID>
TemplateColumn tem = new TemplateColumn();
tem.ItemTemplate.InstantiateIn(txtbox );