Solved

Dynamic Gridview

Posted on 2015-02-18
4
54 Views
Last Modified: 2015-07-13
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.

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

Open in new window


Thanks!
0
Comment
Question by:Clever_Bob
4 Comments
 
LVL 12

Expert Comment

by:jitendra patil
ID: 40618264
can you post your aspx code here?

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=367   '&q=" ' + e.Row.Cells(2).Text
            hLink.Text = e.Row.Cells(2).Text

hope this helps.
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 40620939
For (1)  DataItem contains the data associated with the row:
Dim rowView As DataRowView = CType(e.Row.DataItem, DataRowView)
Dim myID As String = rowView("id prop name")

Open in new window

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

Open in new window

where myID  =  your id value (e.g. 367) from 1
Note: Nice background photo. I played soccer myself as well.
0
 
LVL 10

Accepted Solution

by:
Jini Jose earned 500 total points
ID: 40630172
you can use template columns. Details is given in this link

<asp:TemplateField HeaderText="Hyperlink">
    <ItemTemplate>
        <asp:HyperLink ID="HyperLink1" runat="server" 
            NavigateUrl='<%# Eval("ID", @"GameStatDetails.aspx?Id={0}") %>' 
            Text='Click'>
        </asp:HyperLink>
    </ItemTemplate>
</asp:TemplateField>

Open in new window


http://stackoverflow.com/questions/19798685/how-to-create-a-link-in-gridview-in-asp-net
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question