保存记录时如何找到Runtime TextBox10 id [英] How Runtime TextBox10 id find when we Save record

查看:68
本文介绍了保存记录时如何找到Runtime TextBox10 id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此代码中,如何在运行时查找Textbox10 id,因为这是运行时生成的文本框.

我想保存在文本框中输入的记录.....

亲爱的团队帮我......

我有大问题……


In this code How I find Textbox10 id on runtime because this is runtime generate textbox .

I want to save record which I entered on textbox .....

Dear Team help me....

I have big issue......


RadioButton rdbuttn;
        CheckBox chkList1;
        TextBox txtbox;
        int value = Convert.ToInt32(ddlNumberofAnswer.SelectedValue);
        if (ddlAnswerType.SelectedValue == "2")
        {
            ddlNumberofAnswer.Enabled = true;
            txtTextBox.Visible = false;
            try
            {
                for (int intControlIndex = 0; intControlIndex < value; intControlIndex++)
                {
                    chkList1 = new CheckBox();
                    txtbox = new TextBox();
                    chkList1.ID = "Chk" + intControlIndex;
                    txtbox.ID = "TextBox1" + intControlIndex;
                    chkList1.Font.Name = "Verdana";
                    chkList1.Font.Size = 9;
                    pnlPanel.Controls.Add(chkList1);
                    pnlPanel.Controls.Add(new LiteralControl("<br>"));
                    pnlPanel.Controls.Add(txtbox);
                    pnlPanel.Controls.Add(new LiteralControl("<br>"));
                }
            }
            catch (Exception exp)
            {
                throw new Exception(exp.Message);
            }



[Edited]代码被包装在"pre"标签中[/Edited]



Code is wrapped in "pre" tags[/Edited]

推荐答案

看看FindControl 方法 [

您需要记住的一件事是,根据创建文本框的位置,数据和文本框将在回发中丢失.您可以参考此链接,该链接显示了创建动态控件的不同情况.
One thing you have to remember is ,the data and the textbox will be lost in the post back depending on where you have created your textbox. You can refer this link , which shows different scenarios in creating dynamic controls.


这篇关于保存记录时如何找到Runtime TextBox10 id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆