Click here to Skip to main content
15,040,212 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually i have 2 questions..
Firstly,In my project i want to make one common database between windows form application and web application. So, is this possible to make this kind of shared database in visual studio.???

Secondly, I want to add manual column in gridview i,e. data of that column is not coming from database and i'm calculating it manually. Specifically i want to add Column named "FINE" in gridview which i'm calculating by programming... so tell me if there is any way to add that data into gridview to print my results...
and yeah i want to do above thing in my web application...
Posted

Databases don't care about, nor know anything about, the application that's using them. There is nothing special about a database that make it only usable to a web application or to a Windows application. Both can use the same database at the same time.

Calculated columns can be done in the database itself, if business rules permit, or they can be done in your application code.

How you do this depends on your business logic and how you're doing specific operations. The most general thing to do would be to load your data from the database into a DataTable object, add a new column to it, then iterate over the Rows in the DataTable and calculate your result for each row, putting the value in your new column. Once that's done you can bind your grid to the DataTable for display.
   
First,yes you can have multiple projects, applications, and web sites/applications all pointing to 1 central database.

second there are several ways to get what you want for calculating the extra column. I would most likely make an object that binds to the gridview (and you'll have a list of them 1 for each row) and one of the properties would be the calculated column, either calculate it early and put it in the column or if the property can calculate the value from the other values in the object then I'd do it that way. This will help take more business logic out of the UI. (good programming practice).
   
Comments
Dean_Wi 28-Jan-14 13:20pm
   
can you provide me any example or provide me any link that can help me to understand how to bind object in gridview....
bowlturner 28-Jan-14 13:30pm
   
web apps, win forms and wpf are all a little different. but you bind a property to a column.

if you have a list of objects you can start with

dataGridView1.DataSource = MyListOfObjects;

and then something like this (which happens to be markup)

<columns>
<asp:BoundField DataField="EID" HeaderText="ID" />

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