BulletedList:  Returning values from dynamic list

Posted on 2009-02-19
Last Modified: 2012-06-21

I have a gridview which I have a databound bulletedlist as one of the columns.  I can't seem to get the VALUE of the selected item.  I get the following error that I have attached.
(bl in the example is nothing.  dg is populated with the grid)
Any assistance would be great.  I've gone round and round with this and needed another set(s) of eyes.
Thanks in advance!

Protected Sub BulletedListContent_Click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.BulletedListEventArgs)

        Dim dg As GridView = CType(Me.LoginView1.FindControl("GrdStudents"), GridView)

        Dim bl As BulletedList = CType(dg.FindControl("blcontent"), BulletedList)

        Dim position As Integer = e.Index

        Dim txtcontent As String

        'Dim li As ListItem = blContent.Items(position)

        txtcontent = bl.Items(e.Index).Text

    End Sub


<asp:GridView ID="GrdStudents" runat="server" AutoGenerateColumns="False" DataKeyNames="StudentId,SchYear"

DataSourceID="SqlStudSchool" AllowPaging="True" AllowSorting="True" HeaderStyle-CssClass="datagrid"

CellPadding="4" ForeColor="#333333" GridLines="None" OnRowDataBound="GrdStudents_RowDataBound"

EmptyDataText="No Students to Display">




<asp:TemplateField HeaderText="Content Area">


<asp:BulletedList ID="blContent" runat="server" DataTextField="Content" DataValueField="Content" DisplayMode="LinkButton" OnClick="GrdStudents_bl">



<ItemStyle HorizontalAlign="Left" Width="150px" />



Open in new window

Question by:wayneburr
    LVL 16

    Accepted Solution

    Your line 3 will not find the control as the control is inside an item template that is why it shows the null reference error. has to be something like this
    Dim bl As BulletedList = CType(dg.Rows[0].Cells[<cellnumber>].FindControl("blcontent"), BulletedList)

    Open in new window


    Author Closing Comment

    Very Nice!
    A billion points to you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now