后台生成前台(转)

后台

private void DrawFamilyTable(int personID)
    {
        ds = GetPersonInfo(personID, DocID);
        if (ds.Tables.Count != 0 && ds != null)
        {
            dt = ds.Tables[2];
            if (dt.Rows.Count != 0 && dt != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<table width='100%' border='0' cellpadding='0' cellspacing='1' class='tablebgcolor1'>");
                sb.Append("<tr>");
                sb.Append("<td align='center' class='textalignleft' width='14%' colspan='7' height='26px'>");
                sb.Append("申请人家庭情况");
                sb.Append("</td>");
                sb.Append("</tr>");
                sb.Append("<tr>");
                sb.Append("<td align='center' class='textaligncenter' width='14%' height='26px'>");
                sb.Append("子女姓名");
                sb.Append("</td>");
                sb.Append("<td align='center' class='textaligncenter' width='14%'>");
                sb.Append("是否与老人同住");
                sb.Append("</td>");
                sb.Append("<td align='center' class='textaligncenter' width='14%'>");
                sb.Append("是否在哈市居住");
                sb.Append("</td>");
                sb.Append("<td align='center' class='textaligncenter'>");
                sb.Append("是否享受低保");
                sb.Append("</td>");
                sb.Append("<td align='center' class='textaligncenter'>");
                sb.Append("是否重度残疾");
                sb.Append("</td>");
                sb.Append("<td align='center' class='textaligncenter'>");
                sb.Append("住宅电话");
                sb.Append("</td>");
                sb.Append("<td align='center' class='textaligncenter'>");
                sb.Append("移动电话");
                sb.Append("</td>");
                sb.Append("</tr>");

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sb.Append("<tr>");
                    sb.Append("<td style='text-align:center;' class='right_chaxun_bai' width='14%' height='26px'>");
                    sb.Append(dt.Rows[i]["Name"]);
                    sb.Append("</td>");
                    sb.Append("<td style='text-align:center;' class='right_chaxun_bai' width='14%'>");
                    sb.Append(Convert.ToBoolean(dt.Rows[i]["LiveTogether"]) ? "是" : "否");
                    sb.Append("</td>");
                    sb.Append("<td style='text-align:center;' class='right_chaxun_bai' width='14%'>");
                    sb.Append(Convert.ToBoolean(dt.Rows[i]["IsHarbin"]) ? "是" : "否");
                    sb.Append("</td>");
                    sb.Append("<td style='text-align:center;' class='right_chaxun_bai' width='14%'>");
                    sb.Append(Convert.ToBoolean(dt.Rows[i]["IsBtmS"]) ? "是" : "否");
                    sb.Append("</td>");
                    sb.Append("<td style='text-align:center;' class='right_chaxun_bai' width='14%'>");
                    sb.Append(Convert.ToBoolean(dt.Rows[i]["IsDisable"]) ? "是" : "否");
                    sb.Append("</td>");
                    sb.Append("<td style='text-align:center;' class='right_chaxun_bai' width='14%'>");
                    sb.Append(dt.Rows[i]["Tel"]);
                    sb.Append("</td>");
                    sb.Append("<td style='text-align:center;' class='right_chaxun_bai'>");
                    sb.Append(dt.Rows[i]["MobileNum"]);
                    sb.Append("</td>");
                    sb.Append("</tr>");
                }

                FamilyStr = sb.ToString();
            }
        }
    }

前台

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tablebgcolor1">
                        <tr>
                            <td class="right_chaxun_tdbgc">
                                <%=FamilyStr%>
                            </td>
                        </tr>
                    </table>

.net只不过是把java拆成2个页 所以.net后台定义的变量在前台直接用

就跟Java的jsp页面里定义一个变量直接用是一样的

<html>

<%

String a="sdfa";

%>

........

<%=s%>

<html>

posted @ 2010-11-30 11:38  简单飞翔  阅读(427)  评论(2编辑  收藏  举报