datarow
-
Wednesday, September 21, 2005 11:22 PMhi,
i already have the data from the database in a datatable. i have a column for date, reghours, othours, status.
i want to get the data of a certain date and sum of reghrs(which means there's a possibility that there would be more than one row in a certain date). i have 7.0 in my textbox1. in my textbox2 it will display the difference of my textbox1 and total reg hrs.
All Replies
-
Wednesday, September 21, 2005 11:43 PMModerator
Instead of pulling the entire table into a datatable, it sounds like you should be sending the database a SQL query and retrieving the results in a datatable (or datareader).
Your query would simply be:
SELECT somedate, SUM(reghours) AS reghours
FROM <table>
GROUP BY somedate
Let us know if you need more assistance or if I misunderstood your question,
Josh Lindenmuth -
Thursday, September 22, 2005 1:45 AMthanks. i also have this code and it works fine
foreach ( DataRow row in DTWrkHrsNew.Rows )
{
FinalRegHrs = FinalRegHrs + Convert.ToDouble(row["Regular"]);
}
by the way i've got another problem. i have a textbox when the user input something in it, it will only accept numbers(0-9) and two decimal places only. if the user tries to input other than (0-9) it wont accept or display it. i found this code but i don't think it will work with my code.
function onkeypressRegCheck()
{
if ((event.keyCode == 46) || (event.keyCode > 47 && event.keyCode < 58))
{
return true;
}
else
{
return false;
}
}
i am using C# and ASP .NET
hoping response from you. -
Thursday, September 22, 2005 1:13 PMModeratorWhat happened when you tried using that block of code?
-
Thursday, September 22, 2005 11:13 PM
hi,
the function onkeypressRegCheck() works fine. i just add the javascript in between of the <head> </head> of my html page and in my aspx.cs page on page load i put this code
txtreghrs.Attributes.Add("onkeypress","return onkeypressRegCheck()");
i have another problem the txtreghrs should only accept 2 decimal places if the user will input 3 digits after the decimal the 3rd digit will not be accepted just like what the function onkeypressRegCheck does. -
Friday, September 23, 2005 12:33 AMModerator
There are a few ways you can do this. A lot of people validate and format the textbox after the user tabs out of it (with an lose focus/leave event). This is the easiest.
Otherwise, you'll need to check the position of the decimal place and the position of the key entered to determine whether or not to accept the digit ... I'm not an ASP wiz, so I'm not 100% sure how you'd do this (it took quite a bit of code for us to do this on C# WinForms).
Hope this helps,
Josh Lindenmuth -
Sunday, September 25, 2005 10:22 PMthanks. does it has a big difference when you code in C# Winforms and ASP .NET? could you show me the code?
I will post the code if I am able to get the answer to my question. -
Monday, September 26, 2005 12:14 PMModerator
Hi,
For questions related to ASP.NET there is a dedicated forum here:
http://forums.asp.net/
Please post questions related to ASP.NET on that forum.
Regards,
Vikram

