---
title: "How to get information from DataList&#39;s footer on buttonClick"  
description: "How to get information from DataList&#39;s footer on buttonClick"  
author: "Anonymous User"  
published: 2013-12-18  
updated: 2013-12-18  
canonical: https://www.mindstick.com/forum/1809/how-to-get-information-from-datalist-39-s-footer-on-buttonclick  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# How to get information from DataList&#39;s footer on buttonClick

I have an [ASP.NET](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) [DataList](https://www.mindstick.com/forum/1797/change-text-on-button-in-datalist-not-working), with a footer defined thus:

```
<FooterTemplate>    <asp:DropDownList ID="ddlStatusList" runat="server">    </asp:DropDownList>    <input id="txtNotes" type="text" placeholder="Notes" />    <asp:Button runat="server" type="button" Text="Add" ID="btnAdd"></asp:Button></FooterTemplate>
```

What I'm looking to do, is, on click of btnAdd, get the values from txtNotes and ddlStatusList, but I can't work out how to [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) the [controls](https://www.mindstick.com/articles/66/how-to-create-controls-at-run-time-in-csharp-dot-net), let alone the values.

I can't follow something like this because I won't be able to [check if](https://www.mindstick.com/forum/12878/how-to-check-if-an-asp-dot-net-file-upload-control-has-a-file-in-jquery) my button has been clicked (as is possible with a [checkbox](https://www.mindstick.com/articles/291/how-should-use-checkbox-control-in-vb-dot-net)), and even then, I'm not sure if I'll be able to use findControl as demonstrated. (Does a DataList's footer behave differently to an item?)

I can't use the Button's commandName & commandValue [attributes](https://www.mindstick.com/articles/13105/2-attributes-that-make-your-odoo-ecommerce-theme-productive-and-engaging) because, when databound, the text inputted won't exist and therefore I can't set the CommandValue.

I have tried using a [LinkButton](https://www.mindstick.com/forum/2100/linkbutton-to-expand-gridview-causes-row-colors-from-function-to-be-lost) rather than a normal .NET Button, but come accross the same issue, whereby I cannot work out how to get the values from the [TextBox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview)/[DropDownList](https://www.mindstick.com/articles/324837/how-to-bind-dropdownlist-in-mvc-core-from-database-using-entity-framework)

## Replies

### Reply by Anonymous User

Hi Ankita,\

You can use Control.NamingContainer to access other controls in a row:

```
   
<FooterTemplate>       
<asp:DropDownList ID="ddlStatusList" runat="server">       
</asp:DropDownList>        <input id="txtNotes" type="text" placeholder="Notes" runat="server" />        <asp:Button runat="server" type="button" Text="Add" ID="btnAdd" OnClick="btnAdd_Click"></asp:Button>   
</FooterTemplate>    protected void btnAdd_Click(object sender, EventArgs e)    {        Button btnAdd = (Button)sender;        DropDownList ddlStatusList =(DropDownList)btnAdd.NamingContainer.FindControl("ddlStatusList");       
System.Web.UI.HtmlControls.HtmlInputText txtNotes = (System.Web.UI.HtmlControls.HtmlInputText)btnAdd.NamingContainer.FindControl("txtNotes");        int index = ddlStatusList.SelectedIndex;        string text = txtNotes.Value;    }
```


---

Original Source: https://www.mindstick.com/forum/1809/how-to-get-information-from-datalist-39-s-footer-on-buttonclick

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
