日期:2014-05-18  浏览次数:20893 次

关于AJAX控件的问题
C# code

private void CreatePanel()
    {
        AjaxControlToolkit.TabContainer tc = new AjaxControlToolkit.TabContainer();
        string[] str = new string[9] { "M", "A", "B", "C", "D", "E", "F", "G", "H" };
        int k = 0;
        foreach (DataRow dr in sql.GetDataSet("select * from Item").Tables[0].Rows)
        {
            k++;
            AjaxControlToolkit.TabPanel tp = new AjaxControlToolkit.TabPanel();
            string name = dr["Item_Name"].ToString();
            string html = "";
            tp.HeaderText = dr["Item_Name"].ToString();
            html += "<p style='padding-top:0px; padding-bottom:2px; padding-left:0px; margin-bottom:5px;'>";
            html += dr["Item_Description"].ToString();
            html += "</p>";
            html += "<table  border='0' cellpadding='0' cellspacing='1' bgcolor='#707b8d' width='547px'style=' margin-left:0px;font-size:11px;'>";
            html += "<tr bgcolor='#edf1f3'>";
            html += "<td align='center' height='22px' style='width:30px;'>";
            html += "编号";
            html += "</td>";
            html += "<td align='center'valign='middle' style='width:120px;'>";
            html += "项目名称";
            html += "</td>";
            html += "<td align='center'valign='middle' style='width:350px;'>";
            html += "项目描述";
            html += "</td>";
            html += "<td align='center'valign='middle' style='width:55px;'>";
            html += "需要打√";
            html += "</td>";
            html += "</tr>";

            int b = 0;
            foreach (DataRow dr1 in sql.GetDataSet(string.Format("select * from Project where Item_Id={0}", int.Parse(dr["Item_Id"].ToString()))).Tables[0].Rows)
            {
                b++;
                html += "<tr bgcolor='#FFFFFF'>";
                html += "<td align='center'>";
                html += str[k].ToString() + b.ToString();
                html += "</td>";
                html += "<td>";
                html += dr1["Name"];
                html += "</td>";
                html += "<td>";
                html += dr1["Description"];
                html += "</td>";
                html += "<td align='center'>";
                if ((bool)dr1["Status"])
                {
                    html += "<input id='Checkbox1' type='checkbox' checked=true />";
                }
                else
                {
                    html += "<input id='Checkbox1' type='checkbox' />";
                }
                html += "</td>";
                html += "</tr>";
            }
            html += "</table>";
            html += "<p style='padding-top:5px; padding-bottom:2px; padding-left:0px; margin-bottom:8px;'>";
            html += "其他" + name + "(如需增加其他项目描述,请在下面填写)";
            html += "</p>";
            html += "<p>";
            html += "<textarea id='TextArea1' cols='20' rows='2' style='width: 540px;height:50px;'>";
            html += "</textarea>";
            html += "</p>";
            Label lb = new Label();
            lb.Text = html;
            tp.Controls.Add(lb);
            tc.Controls.A