动态生成Table

Script:

 <tr>

            <td valign="top">

                <table style="width:100%; border-color:Gray; border-style:double; border-width:3">

                    <%=ViewState["ViewCarePlanRiskFactors"]%>

                </table>

            </td>

            <td valign="top">

                <table style="width:100%; border-color:Gray; border-style:double; border-width:3">

                    <%=ViewState["ViewCarePlanGoals/Instructions"]%>

                </table>

            </td>

            <td valign="top">

                <table style="width:100%; border-color:Gray; border-style:double; border-width:3">

                    <%=ViewState["ViewCarePlanInterventions"]%>

                </table>

            </td>

            <td valign="top">

                <table style="width:100%; border-color:Gray; border-style:double; border-width:3">

                    <%=ViewState["ViewPlanMedications"]%>

                    <%=ViewState["ViewCarePlanOtherMedications"]%>

                </table>

            </td>

            <td valign="top">

           <asp:Label runat="server" ID="lblPractitioner"/>

            </td>

        </tr>

Code:

    protected void CreateSectionAndItemStrBasic(Dictionary<string, MyBasicProtocolStructure[]> dictStruc,

            Dictionary<string, MyPatientProtocolItem[]> dictPatientItem,ref string str, string prefixstr, string parentId)

        {

            if (dictStruc.ContainsKey(parentId))

            {

                MyBasicProtocolStructure[] myBasicProtocolStruList = dictStruc[parentId] as MyBasicProtocolStructure[];

                foreach (MyBasicProtocolStructure myBasicProtocolStruc in myBasicProtocolStruList)

                {

                    str += "<tr><td>" + prefixstr + myBasicProtocolStruc.Name + "</td></tr>";

 

                    CreateSectionAndItemStrBasic(dictStruc, dictPatientItem, ref str, "&nbsp;&nbsp;&nbsp;&nbsp;" + prefixstr, myBasicProtocolStruc.Id);

                }

            }

            if (dictPatientItem.ContainsKey(parentId))

            {

                MyPatientProtocolItem[] myPatientProtocolItemList = dictPatientItem[parentId] as MyPatientProtocolItem[];

 

                foreach (MyPatientProtocolItem myPatientProtocolItem in myPatientProtocolItemList)

                {

                    str += "<tr><td>" + prefixstr + myPatientProtocolItem.Content + "</td></tr>";

                }

            }

        }

 

posted @ 2011-12-11 15:20  quietwalk  阅读(879)  评论(0)    收藏  举报