Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7963225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:33:53+00:00 2026-06-04T05:33:53+00:00

I have a TextBox control inside a panel and this panel is inside DataList

  • 0

I have a TextBox control inside a panel and this panel is inside DataList ItemTemplate.

After firing the ItemCommand event, everything works fine except that the TextBox.Text property is always an empty string “” although there is some text in it.

I tried several ways but without success. I would really appreciate if someone can assist me with this. Simplified code is shown below.
Thank you!

ASPX page:

<asp:DataList ID="dlDataList" runat="server" onitemcommand="dlDataList_ItemCommand">
       <ItemTemplate>

           <asp:Panel ID="pnlReply" runat="server" Visible="False">
             <asp:TextBox ID="txtTextBox" runat="server"></asp:TextBox><br />
             <asp:LinkButton ID="lnkbtnSend" CommandName="Send" runat="server">Send</asp:LinkButton>
           </asp:Panel><br />
           <asp:LinkButton ID="OpenPanel" CommandName="OpenPanel" runat="server">Open panel</asp:LinkButton>
       </ItemTemplate>
</asp:DataList>

</asp:Content>

ASPX.CS Page code behind

protected void Page_Load(object sender, EventArgs e)
    {

        FillDataList();

    }

    private void FillDataList()
    {
        List<string> list = new List<string>();
        list.Add("First");
        list.Add("Second");
        list.Add("Third");


        dlDataList.DataSource = list;
        dlDataList.DataBind();
    }

    protected void dlDataList_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "OpenPanel")
        {
            Panel pnlReply = (Panel)e.Item.FindControl("pnlReply");
            pnlReply.Visible = true;
        }
        if (e.CommandName == "Send")
        {
            TextBox txtTextBox = (TextBox)e.Item.FindControl("txtTextBox");
            //I tried this way also..
            //TextBox txtTextBox = (TextBox)e.item.FindControl("pnlReady").FindControl("txtTextBox");
            Label1.Text = txtTextBox.Text;

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:33:54+00:00Added an answer on June 4, 2026 at 5:33 am

    Please use IsPostBack in page load event. Without it your FillDataList(); is executing on every postback and resetting your DataList.

      protected void Page_Load(object sender, EventArgs e)
        {
    
            if (!IsPostBack)
            {
                FillDataList();
    
            }
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Panel control. And inside the panel users can add combobox's, textbox's
I have created a custom TextBox control which also contains a RequiredFieldValidator. Everything works
I have a UpdatePannel Button and a TextBox.Button is inside the UpdatePannel control and
Say i have a TextBox control inside of a ListView where the text is
I have a TextBox control placed inside my window and I would like to
I have Datalist that is inside an updatepanel and it is in panel in
I have a JQuery Dialog, with a control inside containing textbox, I also have
I have a link that is located inside a content control. This link calls
I have the following textbox server control in my web page: <asp:TextBox ID=txtZip runat=server
I have a custom validator attached to a textbox control as follows <td align=center

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.