Setting a default Selection in a dataform

I've got a report that takes a few Selections and I'd like to default a couple of them. I'm pretty sure I have to use a UI Model for this, but I can't quite get it to work. When I debug it, everything is doing exactly what I intend it to do - except that it doesn't actually set the value for the Selection field. Below is the snippet of code that's not quite doing the trick. Any ideas?

private void EVR1014ReportUIModel_Loaded(object sender, Blackbaud.AppFx.UIModeling.Core.LoadedEventArgs e)
{
string query = "select top 1 id from idsetregister where name = 'Event Registrants - Status = Registered (Ad-hoc Query)'";

using (SqlConnection conn = GetRequestContext().OpenAppDBConnection())
{
using (SqlCommand cmd = new SqlCommand(query, conn))
{
object cmdResult = cmd.ExecuteScalar();

Guid defaultRegistrantSelection = Guid.Empty;
if (cmdResult != null && Guid.TryParse(cmdResult.ToString(), out defaultRegistrantSelection))
_pmregistrantselectionid.Value = defaultRegistrantSelection;
}
}

}

Comments