void AddDataBindingLiteral (ControlBuilder builder, DataBindingBuilder db)
{
if (db.Code == null || db.Code.Trim () == "")
return;
EnsureID (db);
CreateField (db, false);
string dbMethodName = "__DataBind_" + db.ID;
// Add the method that builds the DataBoundLiteralControl
InitMethod (db, false, false);
CodeMemberMethod method = db.Method;
AddEventAssign (method, builder, "DataBinding", typeof (EventHandler), dbMethodName);
method.Statements.Add (new CodeMethodReturnStatement (ctrlVar));
// Add the DataBind handler
method = CreateDBMethod (builder, dbMethodName, GetContainerType (builder), typeof (DataBoundLiteralControl));
builder.DataBindingMethod = method;
CodeVariableReferenceExpression targetExpr = new CodeVariableReferenceExpression ("target");
CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression ();
invoke.Method = new CodeMethodReferenceExpression (targetExpr, "SetDataBoundString");
invoke.Parameters.Add (new CodePrimitiveExpression (0));
CodeMethodInvokeExpression tostring = new CodeMethodInvokeExpression ();
tostring.Method = new CodeMethodReferenceExpression (
new CodeTypeReferenceExpression (typeof (Convert)),
"ToString");
tostring.Parameters.Add (new CodeSnippetExpression (db.Code));
invoke.Parameters.Add (tostring);
method.Statements.Add (AddLinePragma (invoke, builder));
mainClass.Members.Add (method);
AddChildCall (builder, db);
}