hyperlink !! please please help...

son

Regular
Joined
Feb 21, 2004
Messages
67
hi hope some one can help...

i have a datagrid which is bounding its fields to a dataset which has an sql string..

i have three columns in my datagrid and the first column is a concatenation of 3 fields from my sql string which is being called by the dataset to be binded to the datagrid..

i am getting really really confused because i need the first column to be a hyperlink to open up another page... (i am coding this in an aspx.vb file so me cant use the property builder);)

i was going to use this procedure below and add a string variable which would be calling a request to a form page(that i have in my project) so that the hyperlink(of the first cell) will open up this requesting page but i cant seem to find my way around it..

Visual Basic:
Private Sub Grid_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) _
            Handles dynamicDataGrid.ItemDataBound

end sub
 
hi hope all is well.. as u can c me still havent solved t problem :( ... anyway me aint gonna give up..

need to ask u one question if ya dont mind

i have this code. You told me to user the hyperlink column .. my question is if i use it instead of the BoundColumn in my SUB DisplayTable Procedure.??. i need it to link the datafield where i have "Vehicle" in my Displaytable procedure, to another page and pass the input parameters which i have declared in my code.. also what i dont know how to do is how to allow the page that i want to link to how to receive these parameters... i know this might be a stupied simple problem but me cant seem to figure it out plus me knew to coding like this... could anyone please help.......

Visual Basic:
Protected WithEvents dynamicDataGrid As System.Web.UI.WebControls.DataGrid
    Protected WithEvents report As System.Web.UI.HtmlControls.HtmlGenericControl


 'Input Parameters
    Private dtFromDate As DateTime
    Private dtToDate As DateTime
    Private strMobileList As String

'url for page to link too
 Private strURL As String


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


strMobileList = Request.Form("Mobiles:selectedMobileList")
        If (strMobileList = "") Then strMobileList = Request.QueryString("Mobile")

        Dim strTemp As String = Request.Form("DateTimeRange:fromDay") & " " & _
                    Request.Form("DateTimeRange:fromMonth") & " " & _
                    Request.Form("DateTimeRange:fromYear") & " " & _
                    Request.Form("DateTimeRange:fromTime")
        If (strTemp = "   ") Then strTemp = Request.QueryString("FromDateTime")
        dtFromDate = Convert.ToDateTime(strTemp, myCulture)

        strTemp = Request.Form("DateTimeRange:toYear") & " " & _
            Request.Form("DateTimeRange:toMonth") & " " & _
            Request.Form("DateTimeRange:toDay") & " " & _
            Request.Form("DateTimeRange:toTime")
        If (strTemp = "   ") Then strTemp = Request.QueryString("ToDateTime")
        dtToDate = Convert.ToDateTime(strTemp, myCulture)


 strURL = Request.Form("CAN_Message_RES_detail")

 'Fetch data
        Dim connCAN_Msg As SqlClient.SqlConnection
        connCAN_Msg = conDB.Connect
        connCAN_Msg.Open()



  'to check whether true or false for the km or miles
        Dim strSQL As String
        Dim a As Boolean
        a = Session("user_miles")

        'to change to miles 
        If a = True Then

            strSQL = _
                             " SELECT Mobile.Label + ' ( ' + Mobile.Registration + ' / ' + CAST(CAN_Message.Locator_ID AS varchar(5)) + ' )' AS Vehicle," & _
                             " SUM(CAN_Message.Distance * .6214) as distance, " & _
                             " SUM(CAN_Message.Fuel_Consumption / CAN_Message.Distance * .6214) as Fuel_Used," & _
                             " AVG(CAN_Message.Fuel_Consumption)  as Consumption_Rate" & _
                             " FROM CAN_Message INNER JOIN " & _
                             " Mobile ON CAN_Message.Locator_ID = Mobile.Mobile_ID " & _
                             " WHERE CAN_Message.Locator_Id IN (" & strMobileList & ") " & _
                             " AND CAN_Message.Creation_Date >=" & strSQLFromDateTime & " AND Creation_Date<=" & strSQLToDateTime & _
                             " GROUP BY Mobile.Label + ' ( ' + Mobile.Registration + ' / ' + CAST(CAN_Message.Locator_ID AS varchar(5)) + ' )' "
        Else
            'to change to km

            strSQL = _
                             " SELECT Mobile.Label + ' ( ' + Mobile.Registration + ' / ' + CAST(CAN_Message.Locator_ID AS varchar(5)) + ' )' AS Vehicle," & _
                             " SUM(CAN_Message.Distance) as distance, " & _
                             " SUM(CAN_Message.Fuel_Consumption / CAN_Message.Distance) as Fuel_Used," & _
                             " AVG(CAN_Message.Fuel_Consumption)  as Consumption_Rate" & _
                             " FROM CAN_Message INNER JOIN " & _
                             " Mobile ON CAN_Message.Locator_ID = Mobile.Mobile_ID " & _
                             " WHERE CAN_Message.Locator_Id IN (" & strMobileList & ") " & _
                             " AND CAN_Message.Creation_Date >=" & strSQLFromDateTime & " AND Creation_Date<=" & strSQLToDateTime & _
                             " GROUP BY Mobile.Label + ' ( ' + Mobile.Registration + ' / ' + CAST(CAN_Message.Locator_ID AS varchar(5)) + ' )' "

        End If


Dim cmdSQL As SqlCommand = New SqlCommand(strSQL, connCAN_Msg)
        Dim daCANMsg As SqlDataAdapter = New SqlDataAdapter(cmdSQL)
        Dim dsCANMsg As DataSet = New DataSet()
        daCANMsg.Fill(dsCANMsg, "CANMsg")


  DisplayTable(dsCANMsg)

 End Sub



Sub DisplayTable(ByVal myDataSet As DataSet)


        dynamicDataGrid = New DataGrid()

        dynamicDataGrid.CssClass = "reportText"
        dynamicDataGrid.CellPadding = 0
        dynamicDataGrid.CellSpacing = 0

        dynamicDataGrid.BorderStyle = BorderStyle.None
        dynamicDataGrid.GridLines = GridLines.None
        dynamicDataGrid.HeaderStyle.CssClass = "reportTextHeader"
        dynamicDataGrid.ItemStyle.CssClass = "reportTextRow"
        dynamicDataGrid.AlternatingItemStyle.CssClass = "reportTextRowAlt"
        dynamicDataGrid.FooterStyle.CssClass = "reportTextFooter"
        dynamicDataGrid.ShowFooter = True
        dynamicDataGrid.AutoGenerateColumns = False

        Dim myDataGridCol As New BoundColumn()
        'myDataGridCol.HeaderImageUrl = "css_reports/reportTextHeaderLeft.jpg"
        myDataGridCol.HeaderStyle.Width = Unit.Percentage(0)
        myDataGridCol.ItemStyle.CssClass = "reportTextBorderLeft"
        dynamicDataGrid.Columns.Add(myDataGridCol)

        myDataGridCol = New BoundColumn()
        myDataGridCol.HeaderText = "Vehicle"
        myDataGridCol.HeaderStyle.CssClass = "col1"
        myDataGridCol.DataField = "Vehicle"
        dynamicDataGrid.Columns.Add(myDataGridCol)


        myDataGridCol = New BoundColumn()
        myDataGridCol.HeaderText = "Distance"
        myDataGridCol.HeaderStyle.CssClass = "col2"
        myDataGridCol.DataField = "Distance"
        dynamicDataGrid.Columns.Add(myDataGridCol)

        myDataGridCol = New BoundColumn()
        myDataGridCol.HeaderText = "Fuel Used"
        myDataGridCol.HeaderStyle.CssClass = "col3"
        myDataGridCol.DataField = "Fuel_Used"
        dynamicDataGrid.Columns.Add(myDataGridCol)

        myDataGridCol = New BoundColumn()
        myDataGridCol.HeaderText = "Consumption Rate"
        myDataGridCol.HeaderStyle.CssClass = "col4"
        myDataGridCol.DataField = "Consumption_Rate"
        dynamicDataGrid.Columns.Add(myDataGridCol)

        myDataGridCol = New BoundColumn()
        myDataGridCol.HeaderStyle.CssClass = "col5"
        myDataGridCol.ItemStyle.CssClass = "reportTextBorderLeft"
        dynamicDataGrid.Columns.Add(myDataGridCol)


        report.Controls.Add(dynamicDataGrid)
        dynamicDataGrid.DataSource = myDataSet
        dynamicDataGrid.DataBind()

    End Sub
 
hi i am checking it out and i am realising that the code is for aspx file
i am coding in a aspx.vb file

that would make a difference in code ej..

sorry for asking a stupied question... but needed to ask..
 
hi just wanted to say thanks loads for ya help..
i managed to complete it and all is working well once again thanks loads u truely r a life saver..;) take care...
 
Back
Top