2.0: DataList with nested LinkButton

R

R.A.M.

Hello,
Please help me in simple problem. I defined DataList, FooterTemplate
with nested asp:LinkButton, and command handler procedure:

<asp:DataList ID="BooksList" runat="server"
OnEditCommand="BooksList_Edit"
OnUpdateCommand="BooksList_Update"
OnCancelCommand="BooksList_Cancel"
OnDeleteCommand="BooksList_Delete">
...
<FooterTemplate>
</tbody>
<tfoot>
<tr align="justify">
<td>
<asp:LinkButton ID="BooksLisAdd"
runat="server" Text="Add" CommandName="Add"
OnCommand="BooksListAdd_Add" />
</td>
</tr>
</tfoot>
</table>
</FooterTemplate>
</asp:DataList>

protected void BooksListAdd_Add(object sender, CommandEventArgs e)
{
...
BooksListAdd.Visible = false; // HERE ERROR: "The
name 'BooksListAdd' does not exist in the current context."
}

Could you explain me please the error and how to solve it?
Thank you very much
/RAM/
 
A

Andrew Robinson

I haven't used a DataList before but you will have to do something along the
line of:

LinkButton linkButon =
(LinkButton)DataListMain.FindControl("LinkButtonAdd");
linkButon.Visible = false;

The control does not exist at compile time so you can't directly reference
it.



Hope this helps,
 
R

R.A.M.

LinkButton linkButon =
(LinkButton)DataListMain.FindControl("LinkButtonAdd");

There's no method FindControl for data list object.
I tried this.FindControl but I got NullReferenceException.
Do you know how to write it?
Thank you very much
/RAM/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top