GridView inside a FormView

  • Thread starter Thread starter Tony WONG
  • Start date Start date
T

Tony WONG

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
 
Gridview rowDataBound will be called upon gridview.DataBind() command.

At most you can try one more thing like calling gridview databind on
formview ondatabound.
 
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.
 
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
***********************
 
Back
Top