Monday, June 30, 2008

I started LINQ- my First program(Linq to XML)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Text;

namespace Linqex_1
{
class Program
{
static void Main(string[] args)
{
XElement xml= new XElement("Bookstore",
new XElement("Book",
new XElement("Author","J K Rowling"),
new XElement("Title","Harry Poter")
),
new XElement("Book",
new XElement("Author","William Sakespeare"),
new XElement("Title","Hamlet")
)
);
xml.Save("c:\\Bookstore.xml");

//Loading xml -Writing Linq Expression to printout element's text
XDocument doc = XDocument.Load("c:\\Bookstore.xml");
var q = from c in doc.Descendants("Book")
select (String) c.Element("Title");

foreach (string s in q)
{
Console.WriteLine(s);
}
Console.WriteLine(xml);

}
}
}

Friday, June 20, 2008

Binding CheckBoxList with Arraylist -A Problem

Though I can bind the ArrayList as a DataSource for the checkBoxList Control, but it became a problem for me. When I tried to get the selected item
----------------------
CheckBoxList1.Items[i].Checked
---------------------------
It always returns false, no matter you check the checkboxes or not.
So, To get rid of this roadblock I had to use DataTable as the DataSource.