动态生成GridViewColumn-创新互联-成都快上网建站

动态生成GridViewColumn-创新互联

#region动态生成gridview

站在用户的角度思考问题,与客户深入沟通,找到阎良网站设计与阎良网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站建设、网站制作、企业官网、英文网站、手机端网站、网站推广、域名申请、网页空间、企业邮箱。业务覆盖阎良地区。

   ///

   ///动态生成gridview

   ///

   ///表名

   privatevoid BindGridView(stringstrName)

   {

       if(!string.IsNullOrEmpty(strName))

       {

           string strSql= string.Format(@"selecta.COLUMN_NAME, t.comments as filed

           fromuser_col_comments t, user_tab_columns a

           wheret.table_name = upper('{0}') and t.table_name = a.TABLE_NAME and t.column_name =a.COLUMN_NAME

           order by filed", strName);

           DataTabledt = OracleHelperImm.getDataTable(strSql);

           if(dt != null && dt.Rows.Count > 0)

           {

               gridList.Columns.Clear();

               BindFixed();

               foreach (DataRow dr in dt.Rows)

               {

                   if (strName == "OWT_blocnew")

                   {

                       if (dr[0].ToString() == "BLOC_NAME")

                       {

                           BoundField bfColumn = newBoundField();

                           bfColumn.DataField = dr[0].ToString();

                           bfColumn.HeaderText = dr[1].ToString();

                           gridList.Columns.Add(bfColumn);

                       }

                   }

                   else

                   {

                       if (dr[0].ToString() != "ID"&& dr[0].ToString() != "WORKORDER_ID")

                       {

                           BoundField bfColumn = newBoundField();

                           bfColumn.DataField = dr[0].ToString();

                           bfColumn.HeaderText = dr[1].ToString();

                           gridList.Columns.Add(bfColumn);

                       }

                   }

               }

           }

       }

       else

       {

           gridList.Columns.Clear();

           BindFixed();

       }

   }

   ///

   ///工单固定列表

   ///

   privatevoid BindFixed()

   {

       TemplateFieldtemplateField0 = new TemplateField();

       templateField0.ItemTemplate = new chkItem1();

       gridList.Columns.Add(templateField0);

       BoundFieldbfColumn10 = new BoundField();

       bfColumn10.DataField = "batch_no";

       bfColumn10.HeaderText = "批次号";

       gridList.Columns.Add(bfColumn10);

       BoundFieldbfColumn11 = new BoundField();

       bfColumn11.DataField = "order_id";

       bfColumn11.HeaderText = "工单号";

       gridList.Columns.Add(bfColumn11);

       BoundFieldbfColumn1 = new BoundField();

       bfColumn1.DataField = "ORDER_STATE";

       bfColumn1.HeaderText = "工单状态";

       gridList.Columns.Add(bfColumn1);

       BoundFieldbfColumn2 = new BoundField();

       bfColumn2.DataField = "type_name";

       bfColumn2.HeaderText = "工单类型";

       gridList.Columns.Add(bfColumn2);

       BoundFieldbfColumn3 = new BoundField();

       bfColumn3.DataField = "CUSTOM_NO";

       bfColumn3.HeaderText = "受理号码";

       bfColumn3.ItemStyle.HorizontalAlign = HorizontalAlign.Right;

       gridList.Columns.Add(bfColumn3);

       BoundFieldbfColumn4 = new BoundField();

       bfColumn4.DataField = "DEAL_NAME";

       bfColumn4.HeaderText = "处理人";

       gridList.Columns.Add(bfColumn4);

       BoundFieldbfColumn5 = new BoundField();

       bfColumn5.DataField = "CREATE_NAME";

       bfColumn5.HeaderText = "创建人";

       gridList.Columns.Add(bfColumn5);

       BoundFieldbfColumn6 = new BoundField();

       bfColumn6.DataField = "COM_NAME";

       bfColumn6.HeaderText = "所属县市";

       gridList.Columns.Add(bfColumn6);

       BoundFieldbfColumn7 = new BoundField();

       bfColumn7.DataField = "CREATE_DATE";

       bfColumn7.HeaderText = "开始时间";

       bfColumn7.ItemStyle.HorizontalAlign = HorizontalAlign.Center;

       gridList.Columns.Add(bfColumn7);

       BoundFieldbfColumn8 = new BoundField();

       bfColumn8.DataField = "LIMITED_TIME";

       bfColumn8.HeaderText = "最后期限";

       bfColumn8.ItemStyle.HorizontalAlign = HorizontalAlign.Center;

       gridList.Columns.Add(bfColumn8);

       BoundFieldbfColumn9 = new BoundField();

       bfColumn9.DataField = "DEAL_DATE";

       bfColumn9.HeaderText = "分公司处理时间";

       bfColumn9.ItemStyle.HorizontalAlign = HorizontalAlign.Center;

       gridList.Columns.Add(bfColumn9);

       BoundFieldbfColumn13 = new BoundField();

       bfColumn13.DataField = "no_answer";

       bfColumn13.HeaderText = "无人接听次数";

       bfColumn13.ItemStyle.HorizontalAlign = HorizontalAlign.Center;

       gridList.Columns.Add(bfColumn13);

       BoundFieldbfColumn14 = new BoundField();

       bfColumn14.DataField = "user_reject";

       bfColumn14.HeaderText = "用户拒接次数";

       bfColumn14.ItemStyle.HorizontalAlign = HorizontalAlign.Center;

       gridList.Columns.Add(bfColumn14);

       BoundFieldbfColumn12 = new BoundField();

       bfColumn12.DataField = "FINISH_DATE";

       bfColumn12.HeaderText = "完成时间";

       bfColumn12.ItemStyle.HorizontalAlign = HorizontalAlign.Center;

       gridList.Columns.Add(bfColumn12);

       TemplateFieldtemplateField = new TemplateField();

       templateField.HeaderText = "操作";

       templateField.ItemTemplate =new chkItem();

       gridList.Columns.Add(templateField);

   }

   publicclass chkItem :Control, ITemplate

   {

       publicvoid InstantiateIn(Controlcontainer)

       {

           HyperLinkchk = new HyperLink();

           chk.ID = "chkItem";

           chk.Text = "下载";

           chk.ForeColor =System.Drawing.Color.Blue;

           container.Controls.Add(chk);

       }

   }

   publicclass chkItem1: Control, ITemplate

   {

       publicvoid InstantiateIn(Controlcontainer)

       {

           HtmlInputCheckBoxcb = new HtmlInputCheckBox();

           cb.ID = "recid";

           container.Controls.Add(cb);

       }

   }

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


名称栏目:动态生成GridViewColumn-创新互联
转载来源:http://kswjz.com/article/gjoic.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流