I have an ASP.NET DataList
, 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 the controls, let alone the values.
I can't follow something like this because I won't be able to check if my button has been clicked (as is possible with a checkbox), 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 because, when databound, the text inputted won't exist and therefore I can't set the CommandValue
.
I have tried using a LinkButton
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
/DropDownList
Following should work. See I added runat="Server" for txtNotes:
aspx:
C#: