B
Bart
Hi,
i defined a linkbutton in a gridview. In code-behind, i want to perform the
delete query when the user clicks on the linkbutton, but this code gives
following error:
"Input string was not in a correct format." at line: r =
Convert.ToInt16(e.CommandArgument)
Thanks for help
Bart
aspx file:
--------
<asp:GridView ID="GridView1" runat="server" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lb1" runat="server" CommandName="Delete"
Text="delete"
OnClientClick="return confirm('Cancel?');" >
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
....
code-behind:
-------------
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
GridView1.RowCommand
Dim r As Int16
Select Case e.CommandName
Case "Delete"
r = Convert.ToInt16(e.CommandArgument)
Me.GridView1.DeleteRow(r)
End Select
End Sub
i defined a linkbutton in a gridview. In code-behind, i want to perform the
delete query when the user clicks on the linkbutton, but this code gives
following error:
"Input string was not in a correct format." at line: r =
Convert.ToInt16(e.CommandArgument)
Thanks for help
Bart
aspx file:
--------
<asp:GridView ID="GridView1" runat="server" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lb1" runat="server" CommandName="Delete"
Text="delete"
OnClientClick="return confirm('Cancel?');" >
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
....
code-behind:
-------------
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
GridView1.RowCommand
Dim r As Int16
Select Case e.CommandName
Case "Delete"
r = Convert.ToInt16(e.CommandArgument)
Me.GridView1.DeleteRow(r)
End Select
End Sub