469,927 Members | 1,780 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Using gridview in a timecard application

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?
Oct 16 '07 #1
7 3151
Use a DataList control. It is capable of rendering multiple items on a row.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Wannabe" <Wa*****@discussions.microsoft.comwrote in message
news:C5**********************************@microsof t.com...
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?

Oct 16 '07 #2
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?

"Eliyahu Goldin" wrote:
Use a DataList control. It is capable of rendering multiple items on a row.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Wannabe" <Wa*****@discussions.microsoft.comwrote in message
news:C5**********************************@microsof t.com...
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?


Oct 16 '07 #3
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.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"Wannabe" <Wa*****@discussions.microsoft.comwrote in message
news:0A**********************************@microsof t.com...
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?

"Eliyahu Goldin" wrote:
Use a DataList control. It is capable of rendering multiple items on a
row.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Wannabe" <Wa*****@discussions.microsoft.comwrote in message
news:C5**********************************@microsof t.com...
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?

Oct 16 '07 #4
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
"Wannabe" wrote:
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?

"Eliyahu Goldin" wrote:
Use a DataList control. It is capable of rendering multiple items on a row.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Wannabe" <Wa*****@discussions.microsoft.comwrote in message
news:C5**********************************@microsof t.com...
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?
Oct 16 '07 #5
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.

"Shaw" wrote:
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
"Wannabe" wrote:
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?

"Eliyahu Goldin" wrote:
Use a DataList control. It is capable of rendering multiple items on a row.
>
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
>
>
"Wannabe" <Wa*****@discussions.microsoft.comwrote in message
news:C5**********************************@microsof t.com...
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?
>
>
>
Oct 17 '07 #6
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
"Wannabe" wrote:
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.

"Shaw" wrote:
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
"Wannabe" wrote:
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?
>
"Eliyahu Goldin" wrote:
>
Use a DataList control. It is capable of rendering multiple items on a row.

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


"Wannabe" <Wa*****@discussions.microsoft.comwrote in message
news:C5**********************************@microsof t.com...
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?

Oct 17 '07 #7
Thanks...that gives me a good starting point. I'll give that a try and repost
if I need any other information.

"Shaw" wrote:
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
"Wannabe" wrote:
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.

"Shaw" wrote:
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
>
>
"Wannabe" wrote:
>
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?

"Eliyahu Goldin" wrote:

Use a DataList control. It is capable of rendering multiple items on a row.
>
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
>
>
"Wannabe" <Wa*****@discussions.microsoft.comwrote in message
news:C5**********************************@microsof t.com...
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?
>
>
>
Oct 17 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Kjetil Klaussen | last post: by
4 posts views Thread by Jim Katz | last post: by
5 posts views Thread by sutphinwb | last post: by
1 post views Thread by jmdolinger | last post: by
reply views Thread by samridhi | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.