asp.net c# ascx

Please view my attached codes...how can i capture the value from the attached code
and save into the database?

protected void BtnSubmit_Click(object sender, EventArgs e)
    {
      //How can I capture the textbox value?
    }

I tried the following codes and it does not work...


TextBox tb = (TextBox)this.Page.FindControl("TxtItem_1");
            if (tb != null)
                Label2.Text = tb.Text;
            else
            {
                Label2.Text = "Nothing";
            }
protected void DdlTotalItem_SelectedIndexChanged(object sender, EventArgs e)
    {
        int TotalItemCount = int.Parse(DdlTotalItem.SelectedValue);
        if (TotalItemCount >= 1)
        {
            // DdlTotalItem.Visible = true;
            MasterListItem.Visible = true;
            MasterListItemTable.Visible = true;
            for (int i = 0; i < TotalItemCount; i++)
            {
                Obout.Interface.OboutTextBox ItemTextBox = new Obout.Interface.OboutTextBox();
                ItemTextBox.ID = "TxtItem_" + i;
                ItemTextBox.Width = 150;

              

                DivItemCode.Controls.Add(ItemTextBox);
                
            }
        }
        else
        {
            MasterListItem.Visible = false;
            MasterListItemTable.Visible = false;
        }
    }

Open in new window

Webboy2008Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kswathiCommented:
You need to find the obout text box i.e.
 Obout.Interface.OboutTextBox tb  =  (Obout.Interface.OboutTextBox)this.Page.FindControl("TxtItem_1");

hope it helps.


0
guramritCommented:
You need to use following code

DivItemCode.FindControl("TxtItem_1");

instead of

this.Page.FindControl("TxtItem_1");

eg.
Obout.Interface.OboutTextBox tb  =  (Obout.Interface.OboutTextBox)DivItemCode.FindControl("TxtItem_1");
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Webboy2008Author Commented:
To both....Your codes won't work because I have a for loop to generate the id for each text box.

how can add a code like FindControl("Txtitem_i")?

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.