Fineui 根据datatable结构动态创建grid列,帮助类。动态绑定grid。
public class FineuiHelper
{
/// <summary>
/// 动态创建Grid结构,在 Page_Init事件里执行(不是Page_Load事件里)
/// </summary>
/// <param name="Grid1">The grid1.</param>
/// <param name="dt">The dt.</param>
public static void CreatGridStructByDataTable(Grid Grid1, DataTable dt)
{
FineUI.BoundField bf;
for (int i = 0; i < dt.Columns.Count; i++)
{
bf = new FineUI.BoundField();
bf.DataField = dt.Columns[i].Caption;
bf.DataFormatString = "{0}";
bf.HeaderText = dt.Columns[i].Caption;
Grid1.Columns.Add(bf);
}
}
}