Problems with Custom Databinding

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++;

}

}
 
C

Cor Ligthert [MVP]

Vivek,

From your code I don't see your problem, your description gives me however
the idea that you want to let your controls show independent from each
others data in one datatable. For that are the extra dataviews.
One dataview is already in the datatable, that one is the defaultview, to
create extra independent dataviews you do

DataView dv1 = new DataView(MyTable);

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top