|  |  | 
          
            | เมื่อเปิดหน้าเพจขึ้นมา จะแสดงข้อมูลทั้งหมด และเมื่อคลิกที่ ImageButton จะทำให้เลือกข้อมูลของรูปนั้นๆ ออกมาควรเขียนโค้ดยังไงดีคะ 
 โค้ดตอนสร้างข้อมูลแบบทั้งหมด
 Code (VB.NET)
 
 Protected Sub BindDataFood()
        Dim da As New SqlDataAdapter(cmd)
        Dim SqlCon As New SqlConnection(con)
        Dim ds As New DataSet()
        Dim dt As New DataTable
        If Session("Store") = "" Then
            SqlCon.Open()
            Dim cmd As New SqlCommand("SELECT st.storeID,st.storeName,stf.foodName,stf.unitPrice,stf.rkey,stf.stock,stf.statusonline  FROM Store st INNER JOIN StoreFood stf On st.storeID=stf.storeID AND st.online='1' AND stf.statusonline='1' ORDER BY st.storeName,stf.foodName ASC", SqlCon)
            da.SelectCommand = cmd
            da.Fill(ds)
            SqlCon.Close()
            If ds.Tables(0).Rows.Count > 0 Then
                Gridview1.DataSource = ds
                Gridview1.DataBind()
            Else
                BuildNoRecord(ds, Gridview1)
            End If
        End If
    End Sub
 ใช้ onItemcommand ในการเรียก ID
 Code (VB.NET)
 
 Protected Sub myDataList_OnItemCommand(sender As Object, e As DataListCommandEventArgs) Handles myDataList.ItemCommand
        If e.CommandName = "Click" Then
            storeID = e.CommandArgument.ToString()
            strStoreID = storeID
            Session("Store") = strStoreID
            'MsgBox(Session("Store"))
        End If
    End Sub
 
 
 Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), VB.NET
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2016-04-28 23:23:54 | By :
                          TinkyWinky | View :
                          888 | Reply :
                          1 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |