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