views:

534

answers:

3

Hello everyone,

I am using VSTS 2008 + C# ASP.Net application type project. My requirement is, I want to let UI designer to work independently with business logics developer. Since UI designer (normally) do not know how to fill Grid View control using code to connect to database. So, my question is, if there are any ways to generate fake data for Grid View control without writing code to connect to database (special needs for UI designer -- to let UI designer have a feel of what data will look like when connecting database to facilitate designer's UI design work)?

thanks in advance, George

+3  A: 

Why don't you generate a

List<Type>()

where Type is a class with the same structure as your real table(s), fill it with data and bind it to your gridview?

eKek0
Using list has the issue that, if I have 50 different Grid Views in my application which UI designer needs to touch, I need to write 50 different Lists. This is another overhead, correct?
George2
You will need to repeat yourself in somewhere if you don't want to provide real data to your UI designer. You could structure your application in layers, for example in Data Access, Bussiness Logic and Presentation layers. In such arquitecture, you could provide fake data from your data access layer with Lists. In the end, my proposal works depending on the arquitecture of your application, wich I don't know
eKek0
List you mean what in .Net more specifically? List<T> or something else?
George2
See my edited answer, please
eKek0
But if we have 50 different grid views, I need to wrote different List instances?
George2
+1  A: 

You could also create your own DataTable in the code behind and populate it with whatever you want for your UI designer to play with.

How is this gridview going to be populated for deployment and do you not have a development database your UI designer could point to instead of using "fake" data? It's a simple thing to write a small bit of code to bind real data to the grid and would likely be more beneficial for the UI designer - it would allow them to potentially see and deal with pagination and sorting of the gridview.

You could also use a few dummy XML files to bind to the gridview - might be simpler/faster and would potentially allow you to switch them out to see different data.

As to the 50 different grid views you mentioned in a comment above, why not write a base class for the pages that will be rendering these views to inherit that handles all of your fake data generation?

Chuck
"create your own DataTable in the code" -- I want to know more specific about your comments. For example, do you mean I create a DataTable and manually fill some data, or do you mean I create a DataTable and connect to backend database?
George2
1. "use a few dummy XML files to bind to the gridview" -- could we use XML to bind to gridview? Interested. Could you recommend some samples for me to learn? 2. "why not write a base class for the pages that will be rendering these views to inherit that handles all of your fake data generation?" -- I have about 50 different tables so I need 50 different grid views. 50 different tables are like employee table, student table, faculty table, etc. In this case, how to write a base class? Is base class an additional overhead because I could simple set source of grid view to specific tables?
George2
Here's a link to an example for binding to xml http://www.codeproject.com/KB/aspnet/Bind_XML_file_to_GridView.aspxI use a base class for some reports that I generate. It handles sorting, paging, exporting to excel, etc. and the report page sets the datasource and binds. Without knowing more about what you're doing I can't say if it would or wouldn't be beneficial.
Chuck
1. But if I have 50 different grid views, I need to generate 50 different XML schemas? 2. And is it double efforts to generate 50 XML schemas (in UI design phase) and 50 tables (in product integration phase)? 3. Besides the XML binding efforts, according to my requirement to facilitate UI design, do you have any other advices?
George2
Personally, I don't understand why your UI designer would need more than a few rows of data for each. It shouldn't take but a few minutes to generate those xml files and the code is a simple copy paste. eKek0 has a good comment/suggestion above. If you don't have time code the architecture and it's not already in place IMO the xml will be fastest to get something to the designer. The better solution would be to mock the data as eKek0 suggests.
Chuck
Thanks, another question is how do bind List to Grid View? In List we could only provide a specific type T, but Grid View needs a table with multiple columns, how to map the specific type T to the table needed for Grid View?
George2
+1  A: 

You could create services marked with [dataobject] and [DataObjectMethodAttribute] that return datatables and dont require parameters. Depending on the size of data you could have these services return all records. It should be easy for the designers to select the service and bind to the grid view through the wizards. They'll also be forced to deal with paging, sorting and can also start to wire in some of the events such as onitemselecting.

In the past I've just allowed my UI designers to just work in HTML. I get them to mock out gridviews with regular tables that I just replace with gridviews when we wire the pages up to data. We typically have use cases or access to the client to determine what fields they want displayed on the gridview.

EDIT: My response took a few hours with kids running around the house.. :) I like the responses above. But, consider using an ado.net dataset and just exposing a default GetAll of the structure.

itchi
1. [dataobject] and [DataObjectMethodAttribute] are both new to me and I did not find a good tutorial for me to pick-up quickly. Do you have any suggested readings for samples to learn? 2. "I get them to mock out gridviews with regular tables" -- you mean you are using the same table in product for UI designer to use during UI designing phase?
George2
3. " We typically have use cases or access to the client to determine what fields they want displayed on the gridview." -- confused, client you mean? I think client is browser in my understanding, I do not know why you need to access browser?
George2
http://www.asp.net/Learn/data-access/tutorial-02-cs.aspx - I always recommend this whole series, it's really good.Sorry, client = who I'm doing work for(usually an end client). So my UI designer either has access to a specification where we've already decided what columns should be present or can ask the question to someone who understands the data in a business context.
itchi
I browsed this tutorial and seems it is not what I need. What I need is how to use dataobject and DataObjectMethodAttribute for a newbie for the attributes (this is the root of my confusion), but this tutorial seems not covering this part.
George2
The benefit of using these attributes is when you create an objectdatasource on a page it will read these attributes and fill in the select methods for you. This can assist people who are newbie and don't know much around this creation. But, if your designers are having trouble with objectdatasources and gridviews I would just let them design with tables and then let the developers come in and clean up.
itchi