Problem with WorkItems and Views

Topics: CAB & Smart Client Software Factory
May 4, 2006 at 7:08 AM
originally posted by: ramyap

I have a list box where I have a list of country each having an ID.
WHen i click on one of them I need to show a form which (technically is View) giving some details of the country, whom i clicked on the list.
I have used a Dataset to bind the controls on the forms.

Now here is the issue.
When i click on a county with say ID 1, it opens the form showing the correct details and the code written for this is as follows:

CountryView cv;
cv = this.WorkItem.Items.AddNew<ClView>(clientId);
ISmartPartInfo cvInfo = new SmartPartInfo();
cvInfo.Title = "Country";
WorkItem.RegisterSmartPartInfo(cv, cvInfo);

Now when i click on another country with say ID as 2, it opens another form/view but the previous view/form opened before also gets overriden with the same details. So right now i have 2 forms opens both having the details of the same country, which is not correct.

The ShowDetails(ID) basically queries the database for the passed ID and gets the result in a Dataset which is then bound to the controls.

I am not sure if there is anything wrong with the code, please help !!!!!
May 4, 2006 at 11:06 AM
originally posted by: DLorenz

cv = this.WorkItem.Items.AddNew<ClView>(clientId);

should be

cv = this.WorkItem.Items.AddNew<ClView>(clientId & ID);

Otherwise, it will pull the same form up every time because it will see that an object with that key already exists and use that instead of creating a new view.
May 4, 2006 at 12:16 PM
originally posted by: ramyap

thanks. will try with it.