如何从asp.net编写和显示web服务

时间:2015-12-02 11:29:36

标签: c# .net xml

此方法将文件读入asp表,然后按下按钮时,文本框中的字段会向tablerow添加新元素。似乎有些东西坏了,我不知道如何解决它。

namespace ReadPeople
{
    public partial class ReadAndWrite : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<People> people = new ReadXml().ReadXmlDoc();
            for(int i=0; i<people.Count; ++i)
            {
                People person = people[i];
            TableRow tr = new TableRow();
            TableCell tcName = new TableCell();
            TableCell tcBirthdate = new TableCell();

            tcName.Text = person.fName + " " + person.lName;
            tcBirthdate.Text = person.month;

            tr.Cells.Add(tcName);
            tr.Cells.Add(tcBirthdate);
            tableAll.Rows.Add(tr);
        }
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        People person = new People();
        person.fName = txtFName.Text;
        person.lName = txtLName.Text;
        person.month = txtMonth.Text;
        WriteXml write = new WriteXml();

        write.WriteToXmlDoc(person);
    }
}

}

0 个答案:

没有答案