[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 444
  • Last Modified:

Bulleted List Master Detail with DisplayMode=LinkButton (C#)

I need to do the following: after calling a web service, the result of that call is a list. I need to display that list in a Master/Detail way using a bulleted list for the Master data and the LinkButton DisplayMode for the Detail data of each item.

With the code I currently have, I can display the Master data of the list with the Button1_click event handler, but I cannot display the details with the BulletedListMedicare_click.

when I use

LabelMedicare3.Text = supList.SupplierDatas[n].CompanyName

to access the data in the list, I get an error. This may have to do with the scope of the list, but I am new to C# so am lost.

Thanks in advance and regards.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Configuration;
using System.Data;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.Adapters;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.Net;

using InfoSoftGlobal;

public partial class Medicare : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)


    protected void Button1_Click(object sender, EventArgs e)
        medicare.MediCareSupplier mc = new medicare.MediCareSupplier();
        medicare.SupplierDataList supList;
        bool resOK;
        resOK = mc.GetSupplierByZipCode(TextBox1.Text, out supList);

        for (int i = 0; i < supList.TotalRecords; i++)



    protected void BulletedListMedicare_click(object sender,BulletedListEventArgs e)
        ListItem li = BulletedListMedicare.Items[e.Index];
        LabelMedicare1.Text = "You selected = " + li.Text + ", with value = "
            + li.Value;
        LabelMedicare2.Text = "The Index of Item you clicked: " + e.Index + "<br> The value of Item you clicked: " + BulletedListMedicare.Items[e.Index].Text;
        int n = e.Index;
LabelMedicare3.Text = supList.SupplierDatas[n].CompanyName;



Open in new window

1 Solution
In your function BulletedListMedicare_click you are referencing supList which does not exist.

In the other function you defined the object supList before accessing its data. So you may just need to add this reference, but without knowing what this class is, and its constructors etc its hard to say for sure.

-> medicare.SupplierDataList supList;

May just need to add that like to your second function, so you have a reference before calling -> supList.SupplierDatas[n].CompanyName;


Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now