asp.net后台自定义标签

ASP.net后台自定义标签。

 

前台:<div  id="DIV_TableCell"  runat="server" ></div>

 

后台:

Dataset  DsOrg=获取集合。

           //为当前先择的部门添加背景图片
            foreach (DataRow DrOrg in DsOrg.Tables[0].Rows)
            {

                divHtml = "<a href='" + this.Page.Request.Path + "?lab=" + DrOrg["OrgID"].ToString() + "'>" + DrOrg["OrgName"].ToString() + "</a>";
                TableCell td1 = new TableCell();
                TableCell td2 = new TableCell();
                TableCell td3 = new TableCell();

                if (SearchValue == DrOrg["OrgName"].ToString())
                {
                   

                    hdf_ConPart.Value = DrOrg["OrgID"].ToString();
                    td1.Attributes.Add("style", "background-image:url(/Views/Test/Image/lab21.gif); background-repeat:no-repeat; width:4px; height:25px;");
                    td2.Attributes.Add("style", "background-image:url(/Views/Test/Image/lab22.gif); background-repeat:repeat-x;");
                    td3.Attributes.Add("style", "background-image:url(/Views/Test/Image/lab23.gif); background-repeat:no-repeat; width:4px; height:25px;");
                }
                else
                {
                    td1.Attributes.Add("style", "background-image:url(/Views/Test/Image/lab11.gif); background-repeat:no-repeat; width:4px; height:25px;");
                    td2.Attributes.Add("style", "background-image:url(/Views/Test/Image/lab12.gif); background-repeat:repeat-x;");
                    td3.Attributes.Add("style", "background-image:url(/Views/Test/Image/lab13.gif); background-repeat:no-repeat; width:4px; height:25px;");
                }

                td2.Controls.Add(new LiteralControl(divHtml));
                this.DIV_TableCell.Controls.Add(td1);
                this.DIV_TableCell.Controls.Add(td2);
                this.DIV_TableCell.Controls.Add(td3);

            }
            

posted on 2011-11-07 17:36  风夜  阅读(1396)  评论(0编辑  收藏  举报