Sunday, November 15, 2009

Text Wrap in GridViews

If you want to make your text wrap in a GridView control, just add the style WORD-BREAK:BREAK-ALL.
protected void gridViewCustomer_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("style", "WORD-BREAK:BREAK-ALL");
}
{

Friday, November 13, 2009

Read XML doc with xmlns using XDocument

Sample Xml File County.xml

<root xmlns="nameSpace">
<county>
<group name="Sutter">
<group name="Yuba">
<group name="Placer">
</group>
</group>
<root>

-----------------------------------------------------------

//C#
XDocument xDoc = XDocument.Load("Country.xml");
XNamespace ns = xDoc.Root.Name.Namespace;

//adding the namespace infront of the XName will allow you to access the node.
var elements = xDoc..Element(ns+"root").Element(ns+"County").Descendants(ns+"Group");

foreach (var element in elements)
{
Console.Write(element.Attribute("name").ToString());
}