尝试删除 gridview 中的一行时,我一直返回错误(输入字符串的格式不正确)
不知道我做错了什么。有什么帮助吗?
<asp:GridView ID="favoritesGrid" runat="server" OnRowDeleting ="favoritesGrid_RowDeleting">
<columns>
<asp:CommandField HeaderText="Delete" ShowDeleteButton="True"/>
<asp:BoundField HeaderText="FavoritesId" DataField="FavoritesId"/>
<asp:TemplateField HeaderText="Site Name">
<ItemTemplate>
<asp:HyperLink ID="myHyperlink"
Text='<%# Eval("SiteName") %>'
NavigateUrl='<%# Eval("Url") %>'
runat="server">
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</columns>
</asp:GridView>
protected void favoritesGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
var delId = Convert.ToInt32(favoritesGrid.Rows[e.RowIndex].Cells[0].Text);
//var id = favoritesGrid.Rows[e.RowIndex].Cells[0].Text;
var delFavorites = new FavoritesDb();
var delFavs = delFavorites.DeleteFavorite(delId);
DataBind();
}