GridView inside a FormView

Discussion in 'ASP .Net' started by Tony WONG, Dec 31, 2009.

  1. Tony WONG

    Tony WONG Guest

    sorry for post too many question

    i have a gridview footer to sum up scores.
    it works fine

    due to the layout and space, then i have to put the GridView inside a
    "FormView"

    But the event handler fails to call the GridView (Handles
    Gridview1.RowDataBound) to sum up the scores.

    Grateful for any help. thx.


    ****** code ****************************
    Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    Gridview1.RowDataBound
    If e.Row.RowType = DataControlRowType.DataRow Then
    MemScore += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,
    "Score"))
    ElseIf e.Row.RowType = DataControlRowType.Footer Then
    e.Row.Cells(2).Text = MemScore.ToString("0")
    End If
    End Sub
     
    Tony WONG, Dec 31, 2009
    #1
    1. Advertising

  2. Tony WONG

    Abdul Sami Guest

    Gridview rowDataBound will be called upon gridview.DataBind() command.

    At most you can try one more thing like calling gridview databind on
    formview ondatabound.

    --
    Abdul Sami


    "Tony WONG" wrote:

    > sorry for post too many question
    >
    > i have a gridview footer to sum up scores.
    > it works fine
    >
    > due to the layout and space, then i have to put the GridView inside a
    > "FormView"
    >
    > But the event handler fails to call the GridView (Handles
    > Gridview1.RowDataBound) to sum up the scores.
    >
    > Grateful for any help. thx.
    >
    >
    > ****** code ****************************
    > Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    > Gridview1.RowDataBound
    > If e.Row.RowType = DataControlRowType.DataRow Then
    > MemScore += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,
    > "Score"))
    > ElseIf e.Row.RowType = DataControlRowType.Footer Then
    > e.Row.Cells(2).Text = MemScore.ToString("0")
    > End If
    > End Sub
    >
    >
    > .
    >
     
    Abdul Sami, Jan 2, 2010
    #2
    1. Advertising

  3. Tony WONG

    Abdul Sami Guest

    Also a control inside formview needs to be called in this way.

    GridView myGridview = (GridView)FormView1.FindControl("GridView1");
    myGridview1.DataBind();

    This will call the gridview1 rowDataBound event for sure.


    --
    Abdul Sami


    "Tony WONG" wrote:

    > sorry for post too many question
    >
    > i have a gridview footer to sum up scores.
    > it works fine
    >
    > due to the layout and space, then i have to put the GridView inside a
    > "FormView"
    >
    > But the event handler fails to call the GridView (Handles
    > Gridview1.RowDataBound) to sum up the scores.
    >
    > Grateful for any help. thx.
    >
    >
    > ****** code ****************************
    > Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    > Gridview1.RowDataBound
    > If e.Row.RowType = DataControlRowType.DataRow Then
    > MemScore += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,
    > "Score"))
    > ElseIf e.Row.RowType = DataControlRowType.Footer Then
    > e.Row.Cells(2).Text = MemScore.ToString("0")
    > End If
    > End Sub
    >
    >
    > .
    >
     
    Abdul Sami, Jan 2, 2010
    #3
  4. Tony WONG

    Tony WONG Guest

    Thank you for your advices

    when the Gridview1.rowdatabound, then it sum up all the rows

    however, after Gridview1 put in a formview
    it cannot locate Gridview1

    the 1st line after Handles has a shadow line under "Gridview1", like this
    Gridview1
    ~~~~~~~

    how can i write rowdatabound event happens in a Gridview inside a formview?

    Thanks a lot.


    ********* vb code *********************
    Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    GridView1.RowDataBound
    code.....................
    End Sub
    ***********************





    "Abdul Sami" <> ¼¶¼g©ó¶l¥ó·s»D:...
    > Also a control inside formview needs to be called in this way.
    >
    > GridView myGridview = (GridView)FormView1.FindControl("GridView1");
    > myGridview1.DataBind();
    >
    > This will call the gridview1 rowDataBound event for sure.
    >
    >
    > --
    > Abdul Sami
    >
    >
    > "Tony WONG" wrote:
    >
    >> sorry for post too many question
    >>
    >> i have a gridview footer to sum up scores.
    >> it works fine
    >>
    >> due to the layout and space, then i have to put the GridView inside a
    >> "FormView"
    >>
    >> But the event handler fails to call the GridView (Handles
    >> Gridview1.RowDataBound) to sum up the scores.
    >>
    >> Grateful for any help. thx.
    >>
    >>
    >> ****** code ****************************
    >> Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    >> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    >> Gridview1.RowDataBound
    >> If e.Row.RowType = DataControlRowType.DataRow Then
    >> MemScore += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,
    >> "Score"))
    >> ElseIf e.Row.RowType = DataControlRowType.Footer Then
    >> e.Row.Cells(2).Text = MemScore.ToString("0")
    >> End If
    >> End Sub
    >>
    >>
    >> .
    >>
     
    Tony WONG, Jan 4, 2010
    #4
  5. Tony WONG

    Tony WONG Guest

    thanks abdul

    finally i understand what you mean.


    "Tony WONG" <> ¼¶¼g©ó¶l¥ó·s»D:...
    > Thank you for your advices
    >
    > when the Gridview1.rowdatabound, then it sum up all the rows
    >
    > however, after Gridview1 put in a formview
    > it cannot locate Gridview1
    >
    > the 1st line after Handles has a shadow line under "Gridview1", like this
    > Gridview1
    > ~~~~~~~
    >
    > how can i write rowdatabound event happens in a Gridview inside a
    > formview?
    >
    > Thanks a lot.
    >
    >
    > ********* vb code *********************
    > Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    > GridView1.RowDataBound
    > code.....................
    > End Sub
    > ***********************
    >
    >
    >
    >
    >
    > "Abdul Sami" <> ¼¶¼g©ó¶l¥ó·s»D:...
    >> Also a control inside formview needs to be called in this way.
    >>
    >> GridView myGridview = (GridView)FormView1.FindControl("GridView1");
    >> myGridview1.DataBind();
    >>
    >> This will call the gridview1 rowDataBound event for sure.
    >>
    >>
    >> --
    >> Abdul Sami
    >>
    >>
    >> "Tony WONG" wrote:
    >>
    >>> sorry for post too many question
    >>>
    >>> i have a gridview footer to sum up scores.
    >>> it works fine
    >>>
    >>> due to the layout and space, then i have to put the GridView inside a
    >>> "FormView"
    >>>
    >>> But the event handler fails to call the GridView (Handles
    >>> Gridview1.RowDataBound) to sum up the scores.
    >>>
    >>> Grateful for any help. thx.
    >>>
    >>>
    >>> ****** code ****************************
    >>> Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    >>> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    >>> Gridview1.RowDataBound
    >>> If e.Row.RowType = DataControlRowType.DataRow Then
    >>> MemScore += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,
    >>> "Score"))
    >>> ElseIf e.Row.RowType = DataControlRowType.Footer Then
    >>> e.Row.Cells(2).Text = MemScore.ToString("0")
    >>> End If
    >>> End Sub
    >>>
    >>>
    >>> .
    >>>

    >
    >
     
    Tony WONG, Jan 7, 2010
    #5
    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. wikkiwikkiwaa
    Replies:
    2
    Views:
    12,614
    wikkiwikkiwaa
    Aug 9, 2006
  2. Tarren
    Replies:
    0
    Views:
    426
    Tarren
    Sep 12, 2006
  3. =?Utf-8?B?QWRhciBXZXNsZXk=?=

    GridView not entering Line Editing mode when inside FormView

    =?Utf-8?B?QWRhciBXZXNsZXk=?=, May 10, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    528
    Steven Cheng[MSFT]
    May 28, 2007
  4. jobs
    Replies:
    0
    Views:
    502
  5. Don
    Replies:
    1
    Views:
    4,728
    Lanoli
    Sep 26, 2008
Loading...

Share This Page