I am very new to VB code but I have created some basic applications using Visual Web Developer 2005. I currently have a Gridview that filters using a dropdown. The dropdown is populated using a SQLDatasource of users. I am currently using the code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DropDownList1.ClearSelection()
DropDownList1.Items.FindByText(User.Identity.Name).Selected = True
End Sub
This gives me an error "Object reference not set to an instance of an object."
Whats am I doing wrong? As I said I am new so please don't be too harsh as I am sure it is a very basic mistake that I am making. Thank you for any help.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DropDownList1.ClearSelection()
DropDownList1.Items.FindByText(User.Identity.Name).Selected = True
End Sub
This gives me an error "Object reference not set to an instance of an object."
Whats am I doing wrong? As I said I am new so please don't be too harsh as I am sure it is a very basic mistake that I am making. Thank you for any help.