Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where do I put code to do this
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01083295
Message ID:
01083697
Vues:
15
>Rick,
>
>Actually they can automatically data bind. Check out the "Data Binding Mere Mortals Windows Forms Controls" and "Data Binding Mere Mortals Web Forms" topics in the MM .NET Dev Guide. There are instructions for specifying the table you want to bind to. If you don't specify a table name the binding defaults to the business object TableName, but you can specify an alternate table name.

Yup, I've seen that and have tried it without success.

(by the way, I'm using v 1.4.2 of the framework)

Here's what I'm doing in the Load of my control
private void ctlSearchCriteria_Load(object sender, System.EventArgs e)
{
  if(!this.DesignMode)
  {
    this.grdItems.BindingSource=_BindingSource;
    this.CreateColumns();
    this.SetColumnHeadings();
    this.SetColumnWidths();
    mmBindingStrategyDataGrid.RegisterBoundControl(this.grdItems);

    if(this.AllowAnyAll)
       BindCheckAllCheckbox();
   }
}

private void BindCheckAllCheckbox()
{
   mmBusinessObject oBiz = this.GetBusinessObject();

   this.chkAll.BindingSource=_BindingSource;
   
   this.chkAll.BindingSourceMember=oBiz.TableName+"AnyAll.All";
   mmBindingStrategySimple.RegisterBoundControl(this.chkAll);
}
So basically the bizobj has two tables - the primary one is pointed to by the TableName. The second table is named as a concatenation of the first table name, and "AnyAll". So if the table name were "Order", the second table would be named "OrderAnyAll". Therefore, the BindingSourceMember is set to "OrderAnyAll.All"

The grid registers fine, but when I step through the mmBindingStrategySimple.RegisterBoundControl(this.chkAll) call, I reach a line of code in mmBindingStrategySimple.BindData(mmControl,mmBusinessObject,mmBusinessStateChange) - line 567 in mmBindingStrategy.cs:
// Only data bind if the table that changed is the same as the
// table (or DataView table) to which this control is bound
if (DataTableName.ToLower() == e.TableName.ToLower() && !mmString.Empty(MemberName))
				{
DataTableName.ToLower() is "orderanyall" and e.TableName.ToLower() is "order" and MemberName is "All", so the binding code within the if statement never runs due to the difference in table names.

The following code is what works now, but could experience problems I mentioned in the first message in this thread:
mmBusinessObject oBiz = this.GetBusinessObject();
DataSet oDS = oBiz.GetCurrentDataSet();
this.chkAll.DataBindings.Clear();
this.chkAll.DataBindings.Add("Checked",oDS,oBiz.TableName+"AnyAll.All");
Maybe I'm calling the wrong binding strategy?
Rick Hodder
MCP Visual Foxpro
C#, VB.NET Developer
Independent Consultant
www.RickHodder.com
MyBlog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform