I have a checkboxlist that displays all the values from a SQL table's XML field. I can get the list of values to display when only one value is checked but not when more than one record is checked. I think I need to add some logic in my codebehind but am not sure where I need to add the code or what code I need to add or how I would bind the checkboxlist on the .aspx page to the codebehind page. How do I do this?
The XML records are stored like this:
<field>
<authors>Robb, Saul, King</authors>
</field>
The checkboxlist is formatted like this:
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" Runat="Server">
<asp:Panel ID="Panel1" runat="server" CssClass="mainContent">
<ContentTemplate>
<asp:FormView runat="server" ID="fvAuthors" DataSourceID="odsAuthorDoc" OnDataBound="fvAuthor_DataBound" OnItemUpdated="fvAuthor_ItemUpdated">
<EditItemTemplate>
<asp:CheckBoxList ID="cblAuthorList" runat="server" Text='<%# Bind("Author") % >' DataSourceID="sdsAuthors" DataTextField="Name" DataValueField="Name"
AppendDataBoundItems = "true" AutoPostBack="true">
<asp:ListItem Text="All Author" Value="All Author" />
</asp:CheckBoxList>
</EditItemTemplate>
</asp:Formview>
</asp:Content>
</asp:Panel>
</ContentTemplate>
Here is the code behind page:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Xml;
namespace Library.Requests
{
public class LibraryDoc : RequestItem
{
private _Author;
public Author { get { return _end; } }
public DateTime StartDate { get { return _start; } }
public LibraryDoc()
: base()
{
}
public LibraryDoc(Int32 RequestID)
: base(ItemID)
{
XmlElement root = _doc.DocumentElement;
XmlNode node;
node = root.SelectSingleNode("Author");
if (node != null) this._author = node.InnerText;
public LibraryDoc(Int32 RequestID, String Title, Int32 RequestedBy, String Author)
: base(RequestID, Title, CreatedBy, 10, Description)
{
this._Author = author
XmlDocument xml = new XmlDocument();
XmlNode root = xml.CreateElement("fields");
xml.AppendChild(root);
node = xml.CreateElement("Author");
node.AppendChild(xml.CreateTextNode(this.Author));
root.AppendChild(node);
//now write everything to SQL
this.WriteXml(xml);
}
public static LibraryDoc GetAuthorDocByID(Int32 RequestID)
{
return new LibraryDoc(RequestID);
}
public static void UpdateLibraryDoc(Int32 LibraryDocID, String Author)
{
LibraryDoc old = LibraryDoc.GetLibraryDocByID(LibraryDocID);
if (old.Author != Author) RequestItem.UpdateField(LibraryDocID, Editor, "Author", Author);
}
}
}