November Happy Hour will be moved to Thursday December 5th.

get text of all the textbox inside episerver pagelist

Vote:
 

Hi I have a episerver pagelist  showing the name of page and textbox field which is editable. Then I have a button in my page which is not inside the pagelist. onclick of this button i want all the values of the textbox. I am trying

private void Button_Click(object sender, System.EventArgs e)
        {
                foreach (PageList item in productList)
                {
                    Response.Write(((TextBox)item.Controls[1]).Text);
                   
                
                }

where productList is the id of the pageList. But dosnt work.Please help

#47168
Jan 18, 2011 8:31
Vote:
 

This isn't necessarily simple or even the way to go (using the PageList control, that is). If you remember the asp.net page lifecycle controls have to be recreated before the Load event to have their values set from the posted values/viewstate. Moreover, the controls have to have identical ID:s/places in the control tree.

Also, you are enumerating over pagelists inside your pagelist, which there are probably none?

I think the asp.net GridView control is better suited for what you are trying to accomplish. You'll find countless examples of using that out there on the web.

#47169
Edited, Jan 18, 2011 9:52
Vote:
 
#47172
Jan 18, 2011 11:08
Vote:
 

Hi,
Thanks for the Reply.

To get this solved I am using the Dictionary Object .I have added the HiddenField in the episerver PageList.

<EPiServer:PageList  runat="server" ID="productList" >        
    <td>Määrä<asp:TextBox ID="txtAmount" runat="server" value="<%# GetTxtValue(Container.CurrentPage.PageLink) %>" ></asp:TextBox>
    <asp:HiddenField  runat="server" ID ="txtAmountH" value="<%# Container.CurrentPage.PageLink %>" />
</EPiServer:PageList>  
 
I am getting the list of both the textbox as well as hiddenField from the Blog solution given by Anders. :)

foreach (HiddenField hiddenf in hiddenList)
    {
        string ID = hiddenf.ClientID;
        ID = ID.Replace("txtAmountH", "txtAmount");
        var TxtBox = from item in boxes
                     where item.ClientID == ID
                     select item;
        if (null != TxtBox)
            dList.Add(hiddenf.Value.ToString(), Convert.ToInt32((TxtBox.First() as TextBox).Text));
    }


and then I an using this Dictionary object to get the values.

}

#47173
Jan 18, 2011 12:04
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.