GridView inside a FormView

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
 
A

Abdul Sami

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

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

Abdul Sami

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.
 
T

Tony WONG

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
***********************
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top