Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I swear, I can't believe there are no examples online (that are easy to find) that demonstrates this... I have to be searching wrong... Ok, here it is... the world's most complicated item to find online...

I have a textbox and a button. I press the button. Button runs SQL command to return data from a stored procedure to the grid control.

Example:

C#
private void SbPatSrch_Click(object sender, RoutedEventArgs e)
		{
			var psm = new PatientSearchModel();
			GcPatRslts.ItemsSource = psm.GridPopulate(TePatLname.Text);
		}


PatientSearchModel is nothing more than C# connecting to the database and running the procedure and returning a data table. TePatLname.Text is the textbox that passes the parameter to the procedure.

Can anyone show me an example of how to do this in MVVM?

What I don't want is another example of a pre-built data table with all the columns and values defined. That's not what I want. That's not real-world. I can't load 1000's of records when the page opens. I need the user to provide values and let the procedure determine what is shown. I understand you likely can't share the database. That's fine. It doesn't have to work on my end. I just need to know that it works on your end. I need to see the pattern and understand the flow. I'm learning MVVM and so far, it just plain sucks. I hear it has great things to offer, but when I can use code behind and write two lines of code versus having files and files of view models and models, it seems like I'm going west until to get to the east side of the street...

What I have tried:

I've reached out to DevExpress and haven't heard back. I downloaded several examples online, but they are filled with garbage (pre-built data tables).
Posted
Updated 18-Dec-18 22:48pm
Comments
TABiSH777 19-Dec-18 2:18am    
Hi, Did you try creating an observablecollection property in viewmodel that you can bind to the item source of your grid control? and a string property that can be binded to your TePatLname text, also a command in view model for your button instead of click? If not, please use command in your button, on execute of that command the value of string property (for textbox) will be passed as parameter to get values from sp & then you can directly assign it to your observablecollection property (for grid control).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900