Using gridview in a timecard application

G

Guest

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?
 
G

Guest

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 said:
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 said:
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?
 
E

Eliyahu Goldin

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 said:
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 said:
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 said:
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?
 
G

Guest

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 said:
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 said:
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 said:
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?
 
G

Guest

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 said:
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 said:
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 said:
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


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?
 
G

Guest

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 said:
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 said:
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 said:
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.

--
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
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?
 
G

Guest

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

Shaw said:
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 said:
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 said:
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
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.

--
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
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top