TheInsider
Programmer
Hi,
I'm trying out the ListView control, and I'm having difficulty accessing the controls within it from my code. For example, if I have the following:
I get an error (CS0103: The name 'btnDelete' does not exist in the current context) when I try to do the following:
I need to be able to code an event for the "Delete" button that is embedded within the ListView control's table, and I would also like to be able to access the chkDelete check boxes from within my code.
Essentially, I want to be able to tell which check boxes were checked when the "Delete" button is clicked.
At the moment, I can't figure out how to access these controls via code. If it matters, I'm using Visual Web Developer 2008 Express Edition.
TIA
I'm trying out the ListView control, and I'm having difficulty accessing the controls within it from my code. For example, if I have the following:
Code:
<asp:ListView ID="lvwMyMemos" runat="server" DataMember="DefaultView" DataSourceID="sqlMyMemos">
<LayoutTemplate>
<table border="1" width="100%">
...
<tr>
<td colspan="6"><asp:Button ID="btnDelete" runat="server" Text="Delete" /></td>
</tr>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td align="center"><input id="chkDelete" type="checkbox" value="<%# Eval("MemoID") %>" /></td>
...
</ItemTemplate>
...
</asp:ListView>
...
I get an error (CS0103: The name 'btnDelete' does not exist in the current context) when I try to do the following:
Code:
protected void Page_Load(object sender, EventArgs e)
{
btnDelete.Click += new EventHandler(btnDelete_Click);
I need to be able to code an event for the "Delete" button that is embedded within the ListView control's table, and I would also like to be able to access the chkDelete check boxes from within my code.
Essentially, I want to be able to tell which check boxes were checked when the "Delete" button is clicked.
At the moment, I can't figure out how to access these controls via code. If it matters, I'm using Visual Web Developer 2008 Express Edition.
TIA