SBA-CDeCinko 0 Light Poster

I am unable to find information for the following situation and hope someone can give me some help.

I have a ListBox, that is in the edit portion of a DetailsView. The ListBox is populated via a SQLDataSource. In the SQLDataSource I am returning an ID, a name and a sortID if the item is selected, NULL if not selected.

I can sucessfully populate the ListBox with all possible choices from the database. I now need to show the ListBox items that are already selected for my detail record for when a user is editing the detail record.

How can I reference and use that value in my SQL data that indicates the item is selected?

In the aspx:

<asp:ListBox ID="sponsors_ListBox" runat="server" DataSourceID="sponsors_SqlDataSource" DataValueField="presenterID" DataTextField="presenter" SelectionMode="Multiple" title="Click to Select a Sponsor">

In the code behind:

protected void session_DetailsView_DataBound(object sender, EventArgs e)
		{
			if (session_DetailsView.CurrentMode == DetailsViewMode.Edit)
			{
				ListBox sponsors_ListBox = session_DetailsView.FindControl("sponsors_ListBox") as ListBox;
				sponsors_ListBox.DataSource

				if (sponsors_ListBox != null)
				{
					foreach (ListItem item in sponsors_ListBox.Items)
					{
						// need a condition here that determines which items to do the following
							item.Selected = true;
					}
				}
			}
		}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.