This has to be way more simple that I am getting. Been searching google for hours with no luck.
Simply stated, I am trying to delete a datalist row which is bound to a mssql database. Simple right!
I am missing where it is putting the key or something because I get getting the error "Object reference not set to an instance of object". I can't figure out how to give it the object!
Page code has the datakey:
<asp:DataList ID="DataList1" runat="server" DataKeyField="cartid" DataSourceID="SqlDataSource1" Width="698px">
Code behind has the code from msdn:
Dim aTable As DataTable aTable = CType(DataList1.DataSource, DataTable) aTable.Rows(e.Item.ItemIndex).Delete() 'reference from here http://msdn.microsoft.com/en-us/library/b7y72882(v=vs.71).aspx
But still getting the error. I am guessing the key isn't getting passed.
I am using asp.net (VB, with Visual Studio 2010, .net 3.5)
Thanks for helping!