码迷,mamicode.com
首页 > 其他好文 > 详细

gridview动态生成列

时间:2014-12-30 18:44:49      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

// 有连接的列
                        if (!String.IsNullOrWhiteSpace(filedModel.C_SqlDetail))
                        {
                            HyperLinkField hyperColumn = new HyperLinkField();
                            hyperColumn.HeaderText = filedModel.DisplayName;
                            hyperColumn.DataTextField = filedModel.DisplayFiled;
                            hyperColumn.NavigateUrl = "javascript:void(0);";
                            hyperColumn.Text = "详细";
                            string[] str = { filedModel.DisplayFiled };
                            hyperColumn.DataNavigateUrlFields = str;
                            hyperColumn.DataNavigateUrlFormatString = "/Statistics/ScanStatisticsDetails?id=" + Request["param"] + "&detailId={0}";
                            gridStatistics.Columns.Add(hyperColumn);

                        }
                        // 普通列
                        else
                        {
                            BoundField newGridBoundColumn = new BoundField();
                            newGridBoundColumn.HeaderText = filedModel.DisplayName;
                            newGridBoundColumn.DataField = filedModel.DisplayFiled;
                            if (filedModel.Length != 0)
                            {
                                newGridBoundColumn.HeaderStyle.Width = filedModel.Length;
                            }
                            this.gridStatistics.Columns.Add(newGridBoundColumn);
                        }
                        dt.Columns.Add(filedModel.DisplayName);
                    }

 

gridview动态生成列

标签:

原文地址:http://www.cnblogs.com/honghong75042/p/4193988.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!