using ITemplate for my gridview help

Discussion in 'ASP .Net' started by rodchar, Apr 28, 2010.

  1. rodchar

    rodchar Guest

    Hi All,

    As in the subject, I'm using ITemplate class for my GridView in ASP.NET
    Fx2.0 VS2005.

    It's a 3 column GridView (FirstName, LastName, TotalAmount)

    How do I add the Footer dynamically for TotalAmount column and then attach
    to total sum field to it all using dynamic columns for my gridview?

    Thanks,
    rodchar
    rodchar, Apr 28, 2010
    #1
    1. Advertising

  2. rodchar

    Andy O'Neill Guest

    "rodchar" <> wrote in message
    news:...
    > Hi All,
    >
    > As in the subject, I'm using ITemplate class for my GridView in ASP.NET
    > Fx2.0 VS2005.
    >
    > It's a 3 column GridView (FirstName, LastName, TotalAmount)
    >
    > How do I add the Footer dynamically for TotalAmount column and then attach
    > to total sum field to it all using dynamic columns for my gridview?
    >
    > Thanks,
    > rodchar


    I understand gridviews in asp.net and have used them extensively.
    I don't understand what you mean by ITemplate.

    The thing to do is to turn the footer on and handle rowdatabound, this code
    does totalling for a gridview.
    I've hacked it about a bit so it's not obvious which system it's out of.

    protected void gv_RowDataBound(object sender, GridViewRowEventArgs
    e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    Total_X += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
    "X"));
    Total_Y += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
    "Y"));
    Total_Z += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
    "Z"));
    }
    if (e.Row.RowType == DataControlRowType.Footer)
    {
    e.Row.Cells[3].Text =
    Total_X.ToString("###,###,###,###.00");
    e.Row.Cells[4].Text =
    Total_Y.ToString("###,###,###,###.00");
    e.Row.Cells[5].Text = Total_ZToString("###,###,###,###.00");
    }
    }
    Andy O'Neill, Apr 28, 2010
    #2
    1. Advertising

  3. rodchar

    rodchar Guest

    Found answer here:
    http://msdn.microsoft.com/en-us/magazine/cc301573.aspx

    "Andy O'Neill" wrote:

    >
    > "rodchar" <> wrote in message
    > news:...
    > > Hi All,
    > >
    > > As in the subject, I'm using ITemplate class for my GridView in ASP.NET
    > > Fx2.0 VS2005.
    > >
    > > It's a 3 column GridView (FirstName, LastName, TotalAmount)
    > >
    > > How do I add the Footer dynamically for TotalAmount column and then attach
    > > to total sum field to it all using dynamic columns for my gridview?
    > >
    > > Thanks,
    > > rodchar

    >
    > I understand gridviews in asp.net and have used them extensively.
    > I don't understand what you mean by ITemplate.
    >
    > The thing to do is to turn the footer on and handle rowdatabound, this code
    > does totalling for a gridview.
    > I've hacked it about a bit so it's not obvious which system it's out of.
    >
    > protected void gv_RowDataBound(object sender, GridViewRowEventArgs
    > e)
    > {
    > if (e.Row.RowType == DataControlRowType.DataRow)
    > {
    > Total_X += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
    > "X"));
    > Total_Y += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
    > "Y"));
    > Total_Z += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
    > "Z"));
    > }
    > if (e.Row.RowType == DataControlRowType.Footer)
    > {
    > e.Row.Cells[3].Text =
    > Total_X.ToString("###,###,###,###.00");
    > e.Row.Cells[4].Text =
    > Total_Y.ToString("###,###,###,###.00");
    > e.Row.Cells[5].Text = Total_ZToString("###,###,###,###.00");
    > }
    > }
    >
    > .
    >
    rodchar, Apr 28, 2010
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John
    Replies:
    0
    Views:
    432
  2. cindy
    Replies:
    0
    Views:
    779
    cindy
    Dec 9, 2009
  3. Using ITemplate as property of a custom control

    , Jan 24, 2007, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    509
    Peter Zolja
    Jan 31, 2007
  4. Chuck P

    GridView ITemplate Columns

    Chuck P, Apr 16, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    197
    Steven Cheng[MSFT]
    Apr 17, 2007
  5. John
    Replies:
    1
    Views:
    166
    myles
    Nov 3, 2008
Loading...

Share This Page