Solved c# ascx

Posted on 2011-10-02
Last Modified: 2012-05-12
Please view my attached 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;
                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;


            MasterListItem.Visible = false;
            MasterListItemTable.Visible = false;

Open in new window

Question by:Webboy2008
    LVL 6

    Expert Comment

    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.

    LVL 4

    Accepted Solution

    You need to use following code


    instead of


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

    Author Comment

    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")?


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
    OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now