Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Using gridview in a timecard application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wannabe - 16 Oct 2007 15:43 GMT
Is there a way to use a gridview in a timecard application, and if so, how? I
was looking at using a gridview to display a person's hours worked in a  
week. To do this, many different data records would have to display on the
same row to make up a week (the database has a new row for each day entered).
But, from what I can tell, this keeps you from being able to use a gridview,
because the gridview relies on one datakey per row (and there are 7 database
records per one gridview row). Is there a way around this, or do I need to
look in a different direction on building my timecard application?
Eliyahu Goldin - 16 Oct 2007 17:12 GMT
Use a DataList control. It is capable of rendering multiple items on a row.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> Is there a way to use a gridview in a timecard application, and if so,
> how? I
[quoted text clipped - 8 lines]
> records per one gridview row). Is there a way around this, or do I need to
> look in a different direction on building my timecard application?
Wannabe - 16 Oct 2007 19:56 GMT
Thanks for the reply, but unless I don't understand the datalist enough, I do
not think that it will work. I need to be able to list a project once, and
then list all hours in a week associated with that project type (would be
multiple records on one line).

So the timecard would look like this:

Project Name     Mon     Tue     Wed     Thu     Fri     Sat     Sun    
Total Hours
Project One        1          3        8          8         8                
           28
Project Two        7         5                                              
             12

A record id would need to be associated with each hours entry so if the user
wanted to edit just those hours, they could. That is where the gridview breaks
down. I can have a gridview display records just as I want, but not with a
record id
associated with each hour entry.

Any suggestions?

> Use a DataList control. It is capable of rendering multiple items on a row.
>
[quoted text clipped - 10 lines]
> > records per one gridview row). Is there a way around this, or do I need to
> > look in a different direction on building my timecard application?
Eliyahu Goldin - 16 Oct 2007 22:53 GMT
Ok, consider the following way:

Reverse to gridview. Databind it to a dataset that will contain a datatable
with the columns corresponding to the ones in the gridview. Populate the
dataset programmatically from the database. Updates to the gridview will
update the dataset. Then save dataset date programmatically to the database.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin

> Thanks for the reply, but unless I don't understand the datalist enough, I do
> not think that it will work. I need to be able to list a project once, and
[quoted text clipped - 32 lines]
> > > records per one gridview row). Is there a way around this, or do I need to
> > > look in a different direction on building my timecard application?
Shaw - 16 Oct 2007 23:13 GMT
I think, the easy way is to refine your DB query and put your work hours and
ids at one record, and store multiple ids at data keys (you can store array
of key at 2.0 and I assume you use 2.0) and access them later.

Shaw

> Thanks for the reply, but unless I don't understand the datalist enough, I do
> not think that it will work. I need to be able to list a project once, and
[quoted text clipped - 32 lines]
> > > records per one gridview row). Is there a way around this, or do I need to
> > > look in a different direction on building my timecard application?
Wannabe - 17 Oct 2007 14:22 GMT
Shaw,

Yes, I am using 2.0. You may have hit on something that I can do, but can
you please explain it a little more.

Just to make sure, here is the hours table structure:
recordid int
projectid int
daterecorded datetime
hours decimal

I need to be able to take up to 7 records (could be less) and combine them
into one row, as shown in another post. For each hour, have it associated
with its own recordid. The projectid for each row would be the same for all
hours in that row (and could be changed, if the user picked the wrong one
initially). If you could explain further about using the datakey property,
that would be great. Thanks.

> I think, the easy way is to refine your DB query and put your work hours and
> ids at one record, and store multiple ids at data keys (you can store array
[quoted text clipped - 38 lines]
> > > > records per one gridview row). Is there a way around this, or do I need to
> > > > look in a different direction on building my timecard application?
Shaw - 17 Oct 2007 18:22 GMT
I am not very sure your database table logic. One possible query is to use
function, such as GetWorkdayHours and GetWorkdayID. So here is a similar
query:

SELECT DISTINCT projected, GetWorkdayHours(‘Monday’, projected ,
weeksatrtday), GetWorkdayHours(‘Tuesday’, projected , weeksatrtday), …,
GetWorkdayID(‘Monday’, projected , weeksatrtday),…
FROM HoursTable
WHERE daterecorded > weeksatrtday AND daterecorded < weeksatrtday

To bind keys (VB):
gridView.DataSource = dataview_name
gridView.DataKeyNames = New String() {"MondayID", “TuesdayID”,…}
gridView.DataBind()

The best way I think, is to modify your database table to fit your needs.

Hope it works (not sure).

Shaw

> Shaw,
>
[quoted text clipped - 56 lines]
> > > > > records per one gridview row). Is there a way around this, or do I need to
> > > > > look in a different direction on building my timecard application?
Wannabe - 17 Oct 2007 18:28 GMT
Thanks...that gives me a good starting point. I'll give that a try and repost
if I need any other information.

> I am not very sure your database table logic. One possible query is to use
> function, such as GetWorkdayHours and GetWorkdayID. So here is a similar
[quoted text clipped - 77 lines]
> > > > > > records per one gridview row). Is there a way around this, or do I need to
> > > > > > look in a different direction on building my timecard application?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.