I followed this site and I got it to work as the site shows - http://aspalliance.com/142_Working_w...s_in_DataGrids
However, with my scenario I need to figure out how to take the ID from the datalist and pass it to my Function:
DataSource="<%# BindSize(DataBinder.Eval(Container.DataItem, "ID")) %>"
This returns a malformed syntax error for the aspx page.
Basically I'm returning a lot of data that has specific data associated with it and I want to dump that data in a DropDownList.
If it can be handled in the codebehind that would be best but when I try that I get "object reference not set to an instance of an object..." for my DDL.
Code Behind attempt:
list.DataSource = datalayer.GetProducts()
BindSizes(list.DataKeyField) 'list.DataKeyField is wrong... I can't figure out how to send the ID.
Private Sub BindSizes(ByVal productId As String)
Dim connection As New OleDbConnection(connectionString)
' Create and initialize the command object
Dim strSQL As String = "SELECT SizeID, ProductID, Sizes & ' - ' & Price AS Sizes, Price " & _
"FROM Sizes " & _
"WHERE (ProductID = " & productid & ")"
Dim objCmd As New OleDbCommand(strSQL, connection)
Dim objDR As OleDbDataReader
Catch e As Exception
Dim myDDL As DropDownList = list.FindControl("ddlSizes")
myDDL.DataSource = objCmd
myDDL.DataTextField = "Sizes"
myDDL.DataValueField = "SizeID"