On Jun 30, 10:30*am, brock wade <brockusw...@yahoo.comwrote:
Another item that may shed some light:
I have this to handle the button in my code-behind:
* * Private Sub LinkButton1_Click(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
* * * * Response.Redirect("Details.aspx?id=" & ID.ToString())
* * End Sub
On Jun 30, 12:11*pm, brock wade <brockusw...@yahoo.comwrote:
I have a Datagrid with the following code:
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>'
runat="server" OnClick="LinkButton1_Click">Details</
asp:LinkButton>Details</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
I'm getting this error message:
Compiler Error Message: BC30456: 'LinkButton1_Click' is not a member
of 'ASP.MainDepartment_aspx'.
Everything looks k in the design view.
What are some places I should think of looking? BTW I'm using .NET 1.1
Thanks!!!
The LinkButton1 method has the wrong signature and you are not using
the correct event. Below is the corrected code:
Private Sub LinkButton1_Click(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.CommandEventArgs)
Response.Redirect("Details.aspx?id=" &
e.CommandArgument.ToString())
End Sub
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>'
runat="server" OnCommand="LinkButton1_Click">Details</
asp:LinkButton>Details</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
There are 3 changes.
1: Instead of using OnClick, use OnCommand. Otherwise you dont get
easy access to the command argument.
2: Change the method signature to the one for the OnCommand event.
3: Change the method to get the id from the command argument instead
of ID. I have no idea where ID came from.
Note: I left the method name alone, but now its confusing. I would
change it to be something like ViewDetails. Something descriptive.
Hope this helps!