Guys, i want to obtain a label value that is within a datagrid; please have a look at the code bellow, and it gives me an NullRefException"Object reference not set to an instance of an object.":
Dim title As String=(DirectCast(VideoDetailsView.FindControl("lblTitle"), Label).Text())
here is my, Data calling and asp.net code
(Data calling: VB.net)
Public Sub GetVideoDetails()
Dim VideoSql As String = "SELECT * FROM VideoList WHERE CategoryID= 5"
Dim ocmd As New OleDbCommand(VideoSql, CreateOleDbConnection)
Dim ds As New DataSet()
Dim ad As New OleDbDataAdapter(ocmd)
ad.Fill(ds)
ds.Dispose()
If Not IsPostBack Then
VideoDetailsView.DataSource = ds.Tables(0)
VideoDetailsView.DataBind()
End If
ocmd.Dispose()
CreateOleDbConnection.Close()
End Sub
(ASP.net code)
Please Note: This Label is within DataGrid
<asp:label ID="lblTitle" runat="server"style="font-family: Arial, Helvetica, sans-serif; font-size: small; font-weight: 700; color: #0066ff;" text='<%# DataBinder.Eval(Container.DataItem, "Tittle")%>' />