0

我在我的 aspx 页面中设计了 2 个表格。table1里面是空白TextArea的。其中table2有 , , 等字段,并且FirstName这些属性已经输入到数据库中。我已经为这些属性输入了相应的符号(例如,名字符号是 {F},姓氏符号是 {L} 等)。LastNameAgeDOB

我的要求是,当我单击Table2(例如FirstName)的字段时,它将显示TextAreatable1“Hi My Name is {F}”。

4

1 回答 1

0

我试过自己做这个程序,但我没有在我的文本区域中提取属性的符号。

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SqlClient;
    using System.Data;
    using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(@"Data Source=AITPLCP72\SQLEXPRESS;Initial Catalog=Template;Integrated Security=True");
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            SqlDataAdapter adp = new SqlDataAdapter("select field,Symbols from temp2", con);
            adp.Fill(ds);
        }
    }
    protected void btnfirstname_onclick(object sender, EventArgs e)
    {
        Symbol("firstname");
    }
    protected void btnlastname_onclick(object sender, EventArgs e)
    {
        Symbol("lastname");
    }
    protected void btnage_onclick(object sender, EventArgs e)
    {
        Symbol("age");
    }
    protected void btndob_onclick(object sender, EventArgs e)
    {
        Symbol("dob");
    }
    protected void btnsubmit_Click1(object sender, EventArgs e)
    {
        string s = TextArea1.InnerHtml;
        Response.Redirect("http://localhost:2482/Template1/Default3.aspx?text1=" + s);
    }


    public void Symbol(string s)
    {
        foreach (DataRow row in ds.Tables[0].Rows)
        {
            if (row[0].ToString() == s.ToString())
            {
                string st = TextArea1.Value;
                st += row["Symbols"];
                TextArea1.Value = st;
            }
        }
    }
}
于 2013-04-13T05:01:10.700 回答