Download it here:
- Reflector 5.0
- Reflector 5.0 Add-Ins @ CodePlex
- Reflector 5.0 New Features (PPT)
More info @ http://www.hanselman.com/blog/Reflector5ReleasedWorldDominationAssured.aspx
Blog about Sharepoint (WSS/MOSS) 2007 & 2010, Web Parts, Workflows, ASP.NET, .NET 3.5
More info @ http://www.hanselman.com/blog/Reflector5ReleasedWorldDominationAssured.aspx
Before reading this post:
When initializing a replicator you need to pass initiation data (like the foreach collection data). So if you want to pass a Contact for each replicated activity, you will set the initiationChildData (must implement IList) with Contact objects:
I will use the example when a dataconnection (webservices) in the form gives a time-out.
Preceding:
First keep in mind that we will bind the dataconnection-webservice to its control in code, so you have to deselect - Automatically retrieve data when form is opened (when adding a data-connection in InfoPath). Also don't forget to link the control with the dataconnection in infopath designer
What we gonna do in code:
- Add a handler that will get you into the Initialize methods of the XmlFormView
- Get the right dataconnection, execute it (so it will get the data and bind to the control)
- Add a "try/catch" block around this code
The code:
void viewform_Initialize(object sender, InitializeEventArgs e)
{
try
{
DataConnection dc = _viewform.XmlForm.DataSources["GetGAL"].QueryConnection;
dc.Execute();
}
catch (System.Net.WebException webEx)
{
WarmUpWebService();
ReloadWebPart();
//Log, ...
}
catch (Exception ex)
{
Logger.Log(ex, ...);
}
}
Some other InfoPath blogs:

(go to Kristof his blog for full explanation)
Which value should the BOOLEANVALUE have to succeed the query?
When you publish a Infopath Form to a sharepoint list, the Infopath form contains some fields (text and date(time) data types). These fields are copied to a sharepoint list when you publish the form to it.

You should think sharepoint keeps the data types like in the infopath form, but this isn't, I noticed that the date(time) data type is just a string/text field in the sharepoint list!
The strange thing is that when you add a column in the published list manualy (for example a datetime field), it will keep the data type and not change it to a string.
I noticed it when a wanted to perform an update an a field called ApprovalDate (Date Datatype) in a Web Part:
SPSite site = new SPSite("http://......");
SPListItemCollection results = site.Lists["InfopathPublishedList"].Items;
foreach (SPListItem item in results)
{
item.Properties["ApprovalDate"] = DateTime.Today;//DateTime.Today.ToString();
item.Update();
}
This code failed when I did this on the datetime field published by infopath:
Error:Specified data type does not match the current data type of the property. at Microsoft.SharePoint.Utilities.SPUtility.UpdateArrayFromHashtable(Object& o, Hashtable ht) at Microsoft.SharePoint.SPListItem.PrepareItemForUpdate(Guid newGuidOnAdd, Boolean bMigration, Boolean& bAdd, Boolean& bPublish, Object&
objAttachmentNames, Object& objAttachmentContents, Int32& parentFolderId) at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration,
Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents) at Microsoft.SharePoint.SPListItem.Update()
This doesn't happen if the ApprovalDate is added by create column in the list.

So watch out, and as you notice in the picture below: It ain't what it look like........
{
private System.Web.UI.WebControls.Calendar ctlCalendar;
protected override void Render(HtmlTextWriter writer)
{
this.EnsureChildControls();
this.ctlCalendar.RenderControl(writer);
}
protected override void CreateChildControls()
{
this.Controls.Clear();
this.ctlCalendar = new System.Web.UI.WebControls.Calendar();
ctlCalendar.VisibleDate = DateTime.Today; this.ctlCalendar.DayRender _
+= new DayRenderEventHandler(ctlCalendar_DayRender);
this.ctlCalendar.VisibleMonthChanged _
+= new MonthChangedEventHandler(ctlCalendar_VisibleMonthChanged);
this.ctlCalendar.SelectionChanged _
+= new EventHandler(ctlCalendar_SelectionChanged); this.Controls.Add(ctlCalendar);
}
void ctlCalendar_SelectionChanged(object sender, EventArgs e)
{
this.Context.Response.Redirect(.......);
}
void ctlCalendar_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
{
ctlCalendar.VisibleDate = e.NewDate;
}
void ctlCalendar_DayRender(object sender, DayRenderEventArgs e)
{
// Set date to bold if its today
Style boldStyle = new Style();
boldStyle.Font.Bold = true;
if (e.Day.Date == DateTime.Today)
{ e.Cell.ApplyStyle(boldStyle); }
}
}
