Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ทำ HyperLink ใน Repeater แล้วมันไม่ขึ้น แก้อย่างไรครับ



 

ทำ HyperLink ใน Repeater แล้วมันไม่ขึ้น แก้อย่างไรครับ

 



Topic : 076086



โพสกระทู้ ( 9 )
บทความ ( 0 )



สถานะออฟไลน์




โดย HyperLink ของผมทำไว้ 3 อันครับ แต่แสดงเพียงอันเดียว
รบกวนหน่อยน่ะครับ

Code (ASP)
Code (VB.NET)
Imports System.Data.OleDb

Public Class user_delete
    Inherits System.Web.UI.Page
    Dim objConn As OleDbConnection
    Dim objCmd As OleDbCommand
    Dim strSQL, strConnString As String
    Dim dtReader As OleDbDataReader

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Label1.Text = "b5051089"
        strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("App_Data/KU.mdb") & ";Jet OLEDB:Database Password=;"

        objConn = New OleDbConnection(strConnString)
        objConn.Open()

        If Not Page.IsPostBack() Then
            BindData()
        End If
    End Sub

    Sub BindData()

        strSQL = "SELECT * FROM Reserv_room WHERE User_ID = '" & Me.Label1.Text & "' "
        objCmd = New OleDbCommand(strSQL, objConn)
        dtReader = objCmd.ExecuteReader()

        '*** BindData to Repeater ***'        
        myRepeater.DataSource = dtReader
        myRepeater.DataBind()

        dtReader.Close()
        dtReader = Nothing
    End Sub

    Sub Page_UnLoad()
        objConn.Close()
        objConn = Nothing
    End Sub


    Private Sub myRepeater__ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles myRepeater.ItemDataBound
        'hplroom แสดงข้อมูลออกมาครับ
        Dim hplroom As HyperLink = CType(e.Item.FindControl("hpl1"), HyperLink)
        If Not IsNothing(hplroom) Then
            hplroom.Text = e.Item.DataItem("RoomID")
            hplroom.NavigateUrl = "http:\\www.google.co.th" 'จำลองลิงค์ไว้ก่อนครับ
        End If
       'hpluser ไม่แสดงข้อมูลครับ
        Dim hpluser As HyperLink = CType(e.Item.FindControl("hpl2"), HyperLink)
        If Not IsNothing(hpluser) Then
            hpluser.Text = e.Item.DataItem("User_ID")
            hpluser.NavigateUrl = "http:\\www.google.co.th"
        End If
       'hplsubject ไม่แสดงข้อมูลเหมือนกันครับ
        Dim hplsubject As HyperLink = CType(e.Item.FindControl("hpl3"), HyperLink)
        If Not IsNothing(hplsubject) Then
            hplsubject.Text = e.Item.DataItem("SubjectID")
            hplsubject.NavigateUrl = "http:\\www.google.co.th"
        End If

        Dim Label4 As Label = CType(e.Item.FindControl("Label4"), Label)
        If Not IsNothing(Label4) Then
            Label4.Text = e.Item.DataItem("Date_reserv")
        End If

        Dim Label5 As Label = CType(e.Item.FindControl("Label5"), Label)
        If Not IsNothing(Label5) Then
            Label5.Text = e.Item.DataItem("Timestart")
        End If

        Dim Label6 As Label = CType(e.Item.FindControl("Label6"), Label)
        If Not IsNothing(Label6) Then
            Label6.Text = e.Item.DataItem("Timefinish")
        End If

        Dim Label7 As Label = CType(e.Item.FindControl("Label7"), Label)
        If Not IsNothing(Label7) Then
            Label7.Text = e.Item.DataItem("Group_ID")
        End If

        Dim Label8 As Label = CType(e.Item.FindControl("Label8"), Label)
        If Not IsNothing(Label8) Then
            Label8.Text = e.Item.DataItem("Status_room")
        End If

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim chkDel As CheckBox
        Dim lblID As HyperLink
        Dim i As Integer
        For i = 0 To myRepeater.Items.Count - 1
            chkDel = myRepeater.Items(i).FindControl("chk1")
            lblID = myRepeater.Items(i).FindControl("hpl1")
            If chkDel.Checked = True Then
                strSQL = "DELETE FROM Reserv_room WHERE RoomID = '" & lblID.Text & "' "
                objCmd = New OleDbCommand(strSQL, objConn)
                objCmd.ExecuteNonQuery()
            End If
        Next
        BindData()
    End Sub
End Class




Tag : .NET, VB.NET







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-03-25 12:09:37 By : lavenderpink View : 911 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code (VB.NET)
        Dim hplroom As HyperLink = CType(e.Item.FindControl("hpl1"), HyperLink)
        If Not IsNothing(hplroom) Then
            hplroom.Text = e.Item.DataItem("RoomID")
            hplroom.NavigateUrl = "http://www.google.co.th" 'จำลองลิงค์ไว้ก่อนครับ
        End If


ลอง Debug ดูครับ มันมีค่าหรือเข้าทำงาน IF นี้หรือเปล่า หรือว่า FindControl ไม่เจอ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-25 22:19:20 By : webmaster
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ทำ HyperLink ใน Repeater แล้วมันไม่ขึ้น แก้อย่างไรครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่