how to fill combo box in silverlight from database - silverlight-4.0

i have a silverlight application.In this i have used service file for DML operations.The methods in Service can be accesed in form page.ie the the XAML page(example Main.XAML)
MY issue is i cant access my DB in the XAML pages as it is in silverlight,i want to create a method in Service file,get some data from MAster tables and fill it in the combo boxes which are there in my first form.
Im trying to use System.Windows.Forms.ComboBox combobox as a control as i cant access the controls of my forms in the service file and then trying to use this control in my form(Main.xaml)then it is showing an error.
Can anyone please let me know how can i populate data this way in combo box.
Rply as early as posible.

You'll need to add an operation to your service that returns a collection of data contracts (for instance a collection of products).
Then call the service from your SL application using an asynchronous call and bind the data to the combo box in the async callback.
There's a working example here.

Related

VB Chat Interface - Displaying Users

I am new to Visual Basic and trying to get around in developing a good gui for a chat interface. I can understand the language as i have been using php and java from quite sometime.
Requirement
Basically i am trying to develop a interface which will show a list of users and along with that display a status (online/offline). My users will reside in mysql database. On clicking the user i want some actions to happen.
Question
I see there is datagrid, listview,listbox but not sure which one to use. Also is it a good idea to display the users by directly quering the mysql database or by accessing a php script which runs few queries and gives the data?
The ListBox control would not be a great option since it doesn't easily support multiple columns. The ListView control in Details view is a great option. I think it looks and works nicer than a DataGrid, but it doesn't natively support multi-line items. If you need multi-line items, the DataGrid control may be your best choice. Another option, which would give you more flexibility, would be to use a LayoutPanel control to display a vertical list of your own UserControl. You could design the UserControl anyway you want meaning you could fully control the size, look, and layout of each item in the list without being constrained by the list control.
As far as getting the data, that depends. If the database is always on the LAN and performance is important, then each client should go directly to the database. Otherwise, getting the data from a php script, web service, or WCF service would be a much better choice.
Rather than using the TableLayoutPanel, I would recommend using the FlowLayoutPanel with the FlowDirection property to TopDown and the AutoScroll property set to True. Then, to add a control dynamically, you could do something like this:
Dim item As New MyUserControl()
' Set properties of user control
FlowLayouPanel1.Controls.Add(item)

How can a custom web part read the list item fields in a display/edit form?

I need to create a custom web part and programmatically attach to the display and edit forms of a list. The web part is meant to display some information (coming from another list) about the list item being displayed on the form.
I know how to add the web part to the list programmatically, but I'm having an issue trying to get the web part to read the list item being displayed on from. I know the SPForm object exposes its parent list but I cannot or don't know how to convert the form to an SPForm object. The parent of the web part is the web part manager and the parent of that is the HTML form object. But when I try convert that to an SPForm object it throws an error.
Also, even if I manage to get hold of the SPForm and its parent list, how can I get hold of the list item being displayed?
Please bear in mind that I need to avoid overwriting the default forms as it will significantly increase the development time.
Any help or idea is appreciated.
Regards

Forcing user to fill some sharepoint item field when trying to set other field on edit form

How to force user to fill some field in edit form when trying to update other choice field to specific value in same sharepoint list item.
I would implement a client side script to implement the logic you need via the xslt style sheet in the edit form.
And Also a server side event handler to make sure that even if the client side logic is overridden you still validate the data on the server. throwing an exception if not valid for instance.
I resover that problem by using list "Validation settings" with rule
=IF([Stan przetargu]="oferowanie";IF(LogotecProj<>"";TRUE;FALSE);TRUE)

Bind a SharePoint list to a Silverlight Dataform

I am using the SharePoint client-object model to read data from a list and I was finally able to correctly get the data but now I am having difficulty actually displaying that data. I would like to use a dataform control to both add and edit the SharePoint list but am thus far unable to get it to actually display the items in the list. If anyone knows how to connect a Dataform control to a sharepoint list I would be very thankful.
You have to bind your list to the control. Have a look at the following page: http://dotnetslackers.com/articles/silverlight/The-DataForm-Control-in-Silverlight-3-Revisited.aspx section "Data binding" explains the steps you need to make (setting the DataContext property).

silverlight domain datasource refreshed only after F5

I am using SL4 with WCF RIA services. I have a domain datasource which I am using to populate a listbox.
I have attached a context menu attached to the list items that I want to trigger an update to a fields value in the database.
so I am trying
EmployeeDetail employee = (EmployeeDetail)sender;
if(employee.EmployeeDetails!=null)
employee.formEmployee.CommitEdit();
dsEmployee.SubmitChanges();
So the code works ok I see the update in the database, however the listbox hasn't been refreshed. If I press F5 then I see the change in the silverlight application however what do I need to do to refresh the lists datasource?
The question is a little bit vague. If your listbox is bound to a collection of EmployeeDetail objects, and they are entities, they will be wrapped in an IObservableCollection<EmployeeDetail>, which means that your listbox should be updated whenever your list is updated in the code behind. However, if you really need to refresh manually, I find that this works:
IObservableCollection<EmployeeDetail> temp = employeeListBox.ItemSource;
employeeListBox.ItemSource = null;
employeeListBox.ItemSource = temp;
If you want to manually refresh a DomainDataSource, you can use the Load() method. If you want to do it on every successful submission, you can subscribe to the SubmittedChanges event and immediately invoke a load.