Clever_Bob
asked on
Dynamic Gridview
Hi!
So I'm trying to update this page here
http://www.bribie.soccerclubstats.com/pageLeague.aspx?leaguename=Bribie%20senior%202015
so that clicking on one of these game results e.g "Old Fellas 9 vs Sandy Gallito 9"
takes you to the page result for that game over here
http://www.bribie.soccerclubstats.com/GameStatDetails.aspx?Id=367
So there are two parts to my problem,
1) I can't work out how to include my data in the Gridview (Id=367) so that I can send it to the next page.
2) I cant work out how to apply this to all of my cells during the GridView_RowDataBound event (the number of columns is dynamic). This is what I've got so far but obviously it only caters for 1 column at the moment.
Thanks!
So I'm trying to update this page here
http://www.bribie.soccerclubstats.com/pageLeague.aspx?leaguename=Bribie%20senior%202015
so that clicking on one of these game results e.g "Old Fellas 9 vs Sandy Gallito 9"
takes you to the page result for that game over here
http://www.bribie.soccerclubstats.com/GameStatDetails.aspx?Id=367
So there are two parts to my problem,
1) I can't work out how to include my data in the Gridview (Id=367) so that I can send it to the next page.
2) I cant work out how to apply this to all of my cells during the GridView_RowDataBound event (the number of columns is dynamic). This is what I've got so far but obviously it only caters for 1 column at the moment.
Protected Sub GridView_RowDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdLeagueSummary.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim hLink As New HyperLink
hLink.NavigateUrl = "GameStatDetails.aspx?Id=367 '.aspx?q=" ' + e.Row.Cells(2).Text
hLink.Text = e.Row.Cells(2).Text
e.Row.Cells(2).Controls.Add(hLink)
End If
End Sub
Thanks!
For (1) DataItem contains the data associated with the row:
Note: Nice background photo. I played soccer myself as well.
Dim rowView As DataRowView = CType(e.Row.DataItem, DataRowView)
Dim myID As String = rowView("id prop name")
For (2) loop using column count but skip the first column:For i As Integer = 1 To gv.Rows.Count - 1
Dim hLink As New HyperLink
hLink.NavigateUrl = "GameStatDetails.aspx?Id=" + myID +"&q=" + e.Row.Cells(i).Text
hLink.Text = e.Row.Cells(i).Text
e.Row.Cells(i).Controls.Add(hLink)
Next
where myID = your id value (e.g. 367) from 1Note: Nice background photo. I played soccer myself as well.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As per your code i think you are trying to bind a grid view with dynamic data source.
Based on the above requirements (1), is it that the 367 value is fixed or it may change during databinding ?
as per the (2) problem i think you need to change the code as below
Dim hLink As New HyperLink
hLink.NavigateUrl = "GameStatDetails.aspx?Id=3
hLink.Text = e.Row.Cells(2).Text
hope this helps.