locked
dropdown list ordering and totalling time RRS feed

  • Question

  • User-39953368 posted

    Hi,

    a couple of questions:

    Even though the stored procedure for getting list of projects and categories orders them project name and category name (actually, category id, but I changed it to category name), the drop downs don't list them as ordered. How can I fix this?

    In the time entry page, how can I display the total hours at the bottom?

    Thanks.

    Thursday, November 8, 2007 5:24 PM

Answers

  • User555306248 posted

    Use Group By clause

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 21, 2007 10:22 PM

All replies

  • User555306248 posted

    You have to modify the SP by Order clause

    For displying total hour at the bottom you have to do manually code

    Sunday, November 11, 2007 10:32 PM
  • User-39953368 posted

    Thanks for the reply.

    The sp does, supposedly, order by name but it does not show up as ordered. That's what was confusing to me. I managed to order the projects by name but the categories still show up as unordered.

    Also, I know that the total has to be done manually, I just need some pointers as how to go about doing it.

    Thanks.

    Tuesday, November 13, 2007 1:49 PM
  • User555306248 posted

    Use Group By clause

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 21, 2007 10:22 PM
  • User-39953368 posted

    Thanks Chetan, it solved the ordering problem. Any idea on how to add a totals row to the bottom of the time sheet grid?

    Tuesday, November 27, 2007 11:29 AM
  • User555306248 posted

    If my answer solved your problem the Mark it as answer

    So it will help for other people

    For adding total rows you can use GridView.Rows.Count It will return total No. of rows

    Wednesday, November 28, 2007 10:31 PM
  • User-39953368 posted

    Thanks Chetan,

    Your reply solved the first part but the second part is still unanswered; that's why I haven't marked it yet.

    By "Total" I meant a row at the bottom of the gridview that would display the totals of values in the columns, not the total number of rows. So, if a column is displaying hours worked, at the bottom I need to be able to display the total number of hours worked. Same for other columns.

    Thanks.

    Friday, November 30, 2007 8:58 AM
  • User-39953368 posted

    I had to enable footer row in the gridview that displays the time sheet and handle the showing of total, in the footer row, through RowDataBound event.

    Thnaks for the help.

    Friday, November 30, 2007 5:25 PM
  • User555306248 posted

    Here is your solution

    http://www.codeproject.com/useritems/SumColumn.asp

    Sunday, December 2, 2007 10:29 PM
  • User555306248 posted

    I have provided you a link.

    Tell me if this useful to you

    Monday, December 3, 2007 10:27 PM
  • User-39953368 posted

    Thanks for the info Chetan. I already solved it (i mentioned it in the reply previously) but thanks for the info again. I am sure it will come in handy.

    However, the link you provided showed as Page Not Found. I found another link, hopefully this is what you meant.

    http://www.codeproject.com/KB/aspnet/SumColumn.aspx

    (Already marked your answer as "the answer")

    Tuesday, December 4, 2007 8:27 PM
  • User555306248 posted

    Thanks

    Tuesday, December 4, 2007 10:33 PM
  • User533367837 posted

    Hi,

    Trying to do something similar with time - can you show your code on how came to the total amount of time?

    Thanks...

    Monday, March 3, 2008 2:18 PM
  • User-39953368 posted

     I declared variable to add the total hours (_dTotalHrs) where I add the values in the "Duration" column. Also I added a RowDataBound event to gridview (MyGridView) and in the code behind I added:

    protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs e)

    {

    if (e.Row.RowType == DataControlRowType.DataRow)

    {

    _dTotalHrs +=
    Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Duration"));

    }

    if (e.Row.RowType == DataControlRowType.Footer)

    {

    e.Row.Cells[0].Text =
    "Totals";e.Row.Cells[4].Text = _dTotalHrs.ToString("#,##0.00");

    }

    }

    Hope this helps.

    Thursday, March 6, 2008 1:01 AM