V
Vivek M
Hello there,
i am running into a databind issues. I am trying to bind a dataview to
collection of user control which are all child of another user control. The
problem is i get the same first row data in all the childrens. Here is my
code:
I call this function in the parent control to add childrens. Could someone
tell me whats the correct way to bind the children to this dataview?
public void AddJobDataView(DataView dv)
{
int Y = this.Header.Height;
this.Header.Size = new Size(this.Width, Y);
this.Footer.Size = new Size(this.Width, this.Footer.Height);
CurrencyManager cm = (CurrencyManager)this.BindingContext[dv];
while (cm.Position < cm.Count)
{
JobListItem item = new JobListItem(); //<-- This is the Child Control
item.Job.DataBindings.Add("Id", dv, "ID");
item.Job.DataBindings.Add("ChangedTime", dv, "LastUpdatedTime");
item.Job.DataBindings.Add("LastStatus", dv, "Last Result");
item.Job.DataBindings.Add("Role", dv, "JobExecutionType");
//item.Job.DataBindings.Add("Suite", dv, "Suite");
item.Job.DataBindings.Add("Title", dv, "Name");
item.Job.DataBindings.Add("Priority", dv, "Priority");
item.Job.DataBindings.Add("Owner", dv, "Owner");
item.Location = new Point(0, Y);
//Update the height of the Collection
Y += item.Height + 1;
this.Height = Y + 10;
//Push the footer down
this.Footer.Location = new Point(0, Y);
//Add the item to the collection
this.Controls.Add(item);
if (cm.Position == cm.Count - 1) break;
cm.Position++;
}
}
i am running into a databind issues. I am trying to bind a dataview to
collection of user control which are all child of another user control. The
problem is i get the same first row data in all the childrens. Here is my
code:
I call this function in the parent control to add childrens. Could someone
tell me whats the correct way to bind the children to this dataview?
public void AddJobDataView(DataView dv)
{
int Y = this.Header.Height;
this.Header.Size = new Size(this.Width, Y);
this.Footer.Size = new Size(this.Width, this.Footer.Height);
CurrencyManager cm = (CurrencyManager)this.BindingContext[dv];
while (cm.Position < cm.Count)
{
JobListItem item = new JobListItem(); //<-- This is the Child Control
item.Job.DataBindings.Add("Id", dv, "ID");
item.Job.DataBindings.Add("ChangedTime", dv, "LastUpdatedTime");
item.Job.DataBindings.Add("LastStatus", dv, "Last Result");
item.Job.DataBindings.Add("Role", dv, "JobExecutionType");
//item.Job.DataBindings.Add("Suite", dv, "Suite");
item.Job.DataBindings.Add("Title", dv, "Name");
item.Job.DataBindings.Add("Priority", dv, "Priority");
item.Job.DataBindings.Add("Owner", dv, "Owner");
item.Location = new Point(0, Y);
//Update the height of the Collection
Y += item.Height + 1;
this.Height = Y + 10;
//Push the footer down
this.Footer.Location = new Point(0, Y);
//Add the item to the collection
this.Controls.Add(item);
if (cm.Position == cm.Count - 1) break;
cm.Position++;
}
}