Java(tm) Servlets and filters
This Blog is first of all memos for me!! From time to time I get exposed to new and cool stuff for developers and architects ,most of the time its a solution for a problem or tips or tricks, so, I would like to track my memos and share it with you, it can save your time and nervous, I hope you will enjoy it - by Yaniv Tzanany.
Search This Blog
Friday, December 30, 2011
JSOS - servlets office suite (servlets)
Probably the largest collection of
Java(tm) Servlets and filters
Java(tm) Servlets and filters
Tuesday, December 27, 2011
asp.net XML binding - how to check field/column exist.
The problem:
when dealing with xml binding , in my case i have attributes on each row.
not all the attributes are existing in the row , so when i use the binding method , i get failed.
e.g.
old code
<div id="divDynmic" runat="server" visible='<%# Eval("AllowDynamicParam").ToString().Trim() == "true" %>'></div>
if AllowDynamicParam is not exist in your xml as an attribute , you get failed.
so i solved this like this - i created the next method :
public string GetData(object o, string key,string defaultValue)
{
GridViewRow gvr = o as GridViewRow;
XPathNavigator nav = ((IXPathNavigable)gvr.DataItem).CreateNavigator();
string attribValue = nav.GetAttribute(key, "");
if (!string.IsNullOrEmpty(attribValue))
return attribValue;
return defaultValue;
}
the main problem was to deal with
gvr.DataItem - its return XmlDataSourceNodeDescriptor object and its sealed - no docs on it.
so my new code look like this:
<div id="divDynmic" runat="server" visible='<%# GetData(Container,"DynamicParamMandatory","false") == "true" %>'></div>
enjoy
Yaniv Tzanany
when dealing with xml binding , in my case i have attributes on each row.
not all the attributes are existing in the row , so when i use the binding method , i get failed.
e.g.
old code
<div id="divDynmic" runat="server" visible='<%# Eval("AllowDynamicParam").ToString().Trim() == "true" %>'></div>
if AllowDynamicParam is not exist in your xml as an attribute , you get failed.
so i solved this like this - i created the next method :
public string GetData(object o, string key,string defaultValue)
{
GridViewRow gvr = o as GridViewRow;
XPathNavigator nav = ((IXPathNavigable)gvr.DataItem).CreateNavigator();
string attribValue = nav.GetAttribute(key, "");
if (!string.IsNullOrEmpty(attribValue))
return attribValue;
return defaultValue;
}
the main problem was to deal with
gvr.DataItem - its return XmlDataSourceNodeDescriptor object and its sealed - no docs on it.
so my new code look like this:
<div id="divDynmic" runat="server" visible='<%# GetData(Container,"DynamicParamMandatory","false") == "true" %>'></div>
enjoy
Yaniv Tzanany
Sunday, December 18, 2011
Sunday, December 11, 2011
Subscribe to:
Posts (Atom)