日期:2014-05-17  浏览次数:20424 次

求一种方法
有一张数据库表,里面是控件TextBox的Id名称,行号和列号

tableA

TextBoxName   Row    columns
TextBox1
TextBox2
TextBox3
TextBox4
TextBox5
TextBox6
TextBox7
TextBox8
TextBox9
TextBox10
TextBox11
TextBox12
TextBox13
TextBox14
TextBox15

我想要这样一个效果:在一个页面上可以设置这些TextBox控件的行号和列号,比如一个页面,左半边以radiobuttonlist的方式显示这些TextBox控件,右半边以20乘以20的方格的形式显示400个按钮,接下来,比如要设置TextBox1的行号和列号,只要先在页面的左半边选中这个控件然后在页面的右半边的方格中选择一个按钮(坐标),然后点击页面上的设置按钮

要实现这个方法可能会比较复杂和麻烦,像这样的方法叫什么名称?有现成的源代码吗?我要搜索的话,应该以什么样的关键字搜索才能搜索到这样的源代码?


------解决方案--------------------
根据名字找控件  Page.FindControl("")
------解决方案--------------------
protected void Page_Load(object sender, EventArgs e)
        {
            Table tb = new Table();
            for (int i = 0; i < 20; i++)
            {
                TableRow row = new TableRow();
                for (int j = 0; j < 20; j++)
                { 
                    TableCell cell = new TableCell();
                    Button bt = new Button();
                    bt.ID = string.Format("bt{0}_{1}", i, j);
                    bt.Text = string.Format("{0}行{1}列", i, j);
                    bt.Click += new EventHandler(bt_Click);
                    cell.Controls.Add(bt);
                    row.Cells.Add(cell);
                }
                tb.Rows.Add(row);
            }

            this.Controls.Add(tb);
        }

        void bt_Click(object sender, EventArgs e)
        {
            Button bt = sender as Button;
            string[] tmp = bt.ID.Replace("bt", string.Empty).Split('_');
 &nb