getting conversion error
I am creating a website using a VB
Error: if I print getID1
Conversion from string to type 'Integer' is not valid.
Error: if I print getID2
NullReferenceException was unhandled by user code. Object reference not set to an instance of an object.
**
.aspx file
**
<asp:DataList ID="DataList1" runat="server" DataKeyField="ID" OnDeleteCommand="DeleteCommand">
<ItemTemplate>
<asp:ImageButton runat="server" ID="deleteIB" CommandName="Delete" ImageUrl="x-icon.png" />
<%# DataBinder.Eval(Container.DataItem, "ID") %>
</ItemTemplate>
</asp:DataList>
**
.aspx.vb file
**
Dim ds As DataSet = New DataSet()
Dim dt As DataTable = New DataTable()
Dim dt As DataTable = New DataTable()
dt.Columns.Add(New DataColumn("ID", GetType(Int32)))
Dim dr As DataRow
...
While reader.Read()
dr = dt.NewRow()
dr(0) = "<a href='" & reader(3) & "' target='_blank'>" & reader(2) & "</a>"
dt.Rows.Add(dr)
End While
...
Protected Sub DeleteCommand(ByVal source As Object, ByVal e As DataListCommandEventArgs)
'Dim getID1 As Integer = CInt(DataList1.DataKeys(e.Item.ItemIndex))
Dim getID2 As String = (CType(e.Item.FindControl("ID"), Label)).Text
ErrorL.Text = getID2
End Sub