Ha ha! I've solved the passsing over issue, it didn't know what to send it back as and I was not explicitly telling the function. I needed to include this extra part on the end of the first line of the function: as TableObjects.DynamicDataSetData
I've been busy with something else lately so I have not had time to put up a sample project for you as you asked before. I'll try to do to it today.
Anyway the only disadvantage for using LINQ to SQL is you need to pre-define object. If your data table is fixed and your list is fixed, your database is Sql server, then using Linq to SQL might be the easiest.
I can not do it because our data table is not fixed (after we deploy our app, the customer can even change the table to add more columns). Our app need to support both Sql server and Oracle (and other DB). The SQL statement in our application is dynamically
build by end user (they use a Filter object and Filter page to define what column they want to see, based on what criteria for each list). In that case, I can not use Linq to SQL because Linq to SQL is still lack those dynamic features. Plus I want to automate
the process to generate each list in our application. So for me using generic data list is the best option.
But every one has different need. If your case is not like ours then you might be better off to use Linq to SQL. It's very a elegent way to do programming. The code is much easier to understand than the generic way. I like it a lot. If I need to write a
simple quick Web application (using Sql server) I definately would choose Linq to SQL.
Sally Xu
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
Thats some sweet code and does an awesome job. I am running into a weird issue though. My column info is getting repeated on every row.
This is what i mean:
Col1 Col2 Col3 Col1 Col2 Col3 State
where Colx is a column in a row. Also, it adds a State Column at the end. When i debug the code, the columns collection does not contain repeated values and it does not contain the "State" column either.
Make sure AutoGenerateColumns="False" on your DataGrid. The "State" Column is a Property for every DataObject to indicate any DataChange for that row. When you build you DataGrid.Columns collection, you should check to skip this column because you do not
want to display it. I'll update my demo when I have time.
The code I provided only meant to show people how to do things this way. It is not the code you can just use without any modification. If you want to go this way, you need to understand the code. Then you can make it work for your case.
Sally Xu
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
I am trying to use your code for the datagrid in my Porject as our requirement is very much similiar to get the data Runtime. I wrote a Store Procedure to get the data, here is what I get:
Description Stage 1 To Stage 2 Stage 2 To Stage 3 Stage 3 To Stage 4
What we want is to do calculations on the editable cells. Here 1st, 3rd and 5th rows 3th and 4th cell is editable. Whenever user changes 60 to anything then the calculation will be as follows:
consider A[0][0] as Untreated cell and likewise others.
so A[1][2] = A[1][1] * (A[0][2] / 100)
A[1][3] = A[1][1] * (A[0][3] / 100 )
but when I edit A[0][2] it updates the dataset but doesnt do the calculation. I hope I made myself clear.
Can you please help me.
Thnanks in advance.
Please "Mark as Answer" if this post answered your question. :)
Visit my Blog
I'm not sure I understand you. Where did put your logic to do the calculation? Do you have code in Silverlight to do the calculation based on user input and update your data that bind to the DataGrid?
Sally Xu
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
peterralphylee
Member
21 Points
11 Posts
Re: How to Display DataSet in Silverlight DataGrid
Jul 17, 2008 05:43 PM | LINK
Ha ha! I've solved the passsing over issue, it didn't know what to send it back as and I was not explicitly telling the function. I needed to include this extra part on the end of the first line of the function: as TableObjects.DynamicDataSetData
RamsZone
Member
160 Points
159 Posts
Re: How to Display DataSet in Silverlight DataGrid
Jul 22, 2008 01:11 PM | LINK
Hi Sladapter,
I have to save changes made in data grid to the database.
I have tried to find the modified object in the RowEdited, DataGridColumn_EndEditing events.
But I am not able find the RowOject because this solution is mainly for generic data display.
Is there any disadvantages in using LINQ to SQL ?I think we can achieve this easily using LINQ to SQL.
Could you please suggest me a better way to reflect datagrid changes in database.
Thanks in advance,
Rams.
sladapter
All-Star
43607 Points
7907 Posts
Re: How to Display DataSet in Silverlight DataGrid
Jul 22, 2008 03:10 PM | LINK
I've been busy with something else lately so I have not had time to put up a sample project for you as you asked before. I'll try to do to it today.
Anyway the only disadvantage for using LINQ to SQL is you need to pre-define object. If your data table is fixed and your list is fixed, your database is Sql server, then using Linq to SQL might be the easiest.
I can not do it because our data table is not fixed (after we deploy our app, the customer can even change the table to add more columns). Our app need to support both Sql server and Oracle (and other DB). The SQL statement in our application is dynamically build by end user (they use a Filter object and Filter page to define what column they want to see, based on what criteria for each list). In that case, I can not use Linq to SQL because Linq to SQL is still lack those dynamic features. Plus I want to automate the process to generate each list in our application. So for me using generic data list is the best option.
But every one has different need. If your case is not like ours then you might be better off to use Linq to SQL. It's very a elegent way to do programming. The code is much easier to understand than the generic way. I like it a lot. If I need to write a simple quick Web application (using Sql server) I definately would choose Linq to SQL.
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
RamsZone
Member
160 Points
159 Posts
Re: How to Display DataSet in Silverlight DataGrid
Jul 22, 2008 04:05 PM | LINK
Hi Sladapter,
Thank you very much for your continuous support.
You are right. LINQ to SQL lack dynamic feature which is very important for our applications.
I have tried like this
- In GetData.cs I have created a function which return list of objects some thing like this.
public List<Order> GetOrders(string Sql){
--------------------------
}
[OperationContract]
List<Order> GetOrders(string SQL);
When I try to update service reference I am getting the following error.
The remote server returned an error:(415) Unsupported media type.
Anyway.... I am waiting for your code.[:)]
Thanks again,
Rams.
sladapter
All-Star
43607 Points
7907 Posts
Re: How to Display DataSet in Silverlight DataGrid
Jul 28, 2008 06:09 PM | LINK
Rams,
The link is updated. You can get the latest now.
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
RamsZone
Member
160 Points
159 Posts
Re: How to Display DataSet in Silverlight DataGrid
Jul 28, 2008 07:25 PM | LINK
Hi Sladapter,
Thanks you very much for spending your valuable time for me.
I will check this and get back to you soon.
Thanks again.
Rams.
mithunster
Member
4 Points
45 Posts
Re: How to Display DataSet in Silverlight DataGrid
Feb 26, 2009 08:33 PM | LINK
Thats some sweet code and does an awesome job. I am running into a weird issue though. My column info is getting repeated on every row.
This is what i mean:
Col1 Col2 Col3 Col1 Col2 Col3 State
where Colx is a column in a row. Also, it adds a State Column at the end. When i debug the code, the columns collection does not contain repeated values and it does not contain the "State" column either.
Any help would be appreciated.
Thanks,
sladapter
All-Star
43607 Points
7907 Posts
Re: How to Display DataSet in Silverlight DataGrid
Feb 26, 2009 08:59 PM | LINK
Make sure AutoGenerateColumns="False" on your DataGrid. The "State" Column is a Property for every DataObject to indicate any DataChange for that row. When you build you DataGrid.Columns collection, you should check to skip this column because you do not want to display it. I'll update my demo when I have time.
The code I provided only meant to show people how to do things this way. It is not the code you can just use without any modification. If you want to go this way, you need to understand the code. Then you can make it work for your case.
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question
varshavmane
Star
13229 Points
2753 Posts
Re: How to Display DataSet in Silverlight DataGrid
Mar 06, 2009 08:27 AM | LINK
Hello Sladapter,
I am trying to use your code for the datagrid in my Porject as our requirement is very much similiar to get the data Runtime. I wrote a Store Procedure to get the data, here is what I get:
Description Stage 1 To Stage 2 Stage 2 To Stage 3 Stage 3 To Stage 4
----------------------------------------------------------------------------------------------------------------------------------------
Untreated 100.00 60.00 40.00
Quarters 5.00 3.00 2.00
Deaths 100.00 50.00 20.00
Quarters 3.00 1.50 0.60
Cures 100.00 50.00 50.00
Quarters 4.00 2.00 2.00
What we want is to do calculations on the editable cells. Here 1st, 3rd and 5th rows 3th and 4th cell is editable. Whenever user changes 60 to anything then the calculation will be as follows:
consider A[0][0] as Untreated cell and likewise others.
so A[1][2] = A[1][1] * (A[0][2] / 100)
A[1][3] = A[1][1] * (A[0][3] / 100 )
but when I edit A[0][2] it updates the dataset but doesnt do the calculation. I hope I made myself clear.
Can you please help me.
Thnanks in advance.
Visit my Blog
sladapter
All-Star
43607 Points
7907 Posts
Re: How to Display DataSet in Silverlight DataGrid
Mar 06, 2009 02:04 PM | LINK
varshavmane,
I'm not sure I understand you. Where did put your logic to do the calculation? Do you have code in Silverlight to do the calculation based on user input and update your data that bind to the DataGrid?
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question