L
Lerp
Hi,
I have this sub in which I am trying to get a client name from a second
table based on a clientid value in my datalist. I am having problems
grabbing the clientid value out of my datalist and putting it into my
variable curClientID. How do you grab a value out of a datalist properly
please?
Thx,Lerp
Here's my sub:
'THIS SUB HANDLES GRABBING CLIENT NAMES
Sub dlBookings_OnItemDataBound(sender As Object, e As DataListItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim ClientNameLabel As Label =
e.Item.FindControl("clientnamelabel")
'Trying to grab clientid here
********************************************
Dim curClientID
curClientID = e.item.FindControl("clientid")....
********************************************
' GRAB client name using ID from db here
Dim clientlabel As String
Dim strSQL as String
'SQL STATEMENT
strSQL = "SELECT fullname FROM CLIENT WHERE clientid=" & curClientID
'NEW CONNECTION OBJECT
Dim MyConn as New
SQLConnection(ConfigurationSettings.AppSettings("dbConn"))
'NEW DATAREADER
Dim objDR as SQLDataReader
'NEW COMMAND OBJECT
Dim Cmd as New SQLCommand(strSQL, MyConn)
'OPEN CONNECTION
MyConn.Open()
'EXECUTE QUERY AND RETRIEVE DATA INTO READER
objDR = Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
WHILE objDR.Read
clientlabel = objDR("fullname")
END While
myConn.close
'redisplay it in the DataList.
clientnamelabel.Text = clientlabel
End If
End Sub
I have this sub in which I am trying to get a client name from a second
table based on a clientid value in my datalist. I am having problems
grabbing the clientid value out of my datalist and putting it into my
variable curClientID. How do you grab a value out of a datalist properly
please?
Thx,Lerp
Here's my sub:
'THIS SUB HANDLES GRABBING CLIENT NAMES
Sub dlBookings_OnItemDataBound(sender As Object, e As DataListItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim ClientNameLabel As Label =
e.Item.FindControl("clientnamelabel")
'Trying to grab clientid here
********************************************
Dim curClientID
curClientID = e.item.FindControl("clientid")....
********************************************
' GRAB client name using ID from db here
Dim clientlabel As String
Dim strSQL as String
'SQL STATEMENT
strSQL = "SELECT fullname FROM CLIENT WHERE clientid=" & curClientID
'NEW CONNECTION OBJECT
Dim MyConn as New
SQLConnection(ConfigurationSettings.AppSettings("dbConn"))
'NEW DATAREADER
Dim objDR as SQLDataReader
'NEW COMMAND OBJECT
Dim Cmd as New SQLCommand(strSQL, MyConn)
'OPEN CONNECTION
MyConn.Open()
'EXECUTE QUERY AND RETRIEVE DATA INTO READER
objDR = Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
WHILE objDR.Read
clientlabel = objDR("fullname")
END While
myConn.close
'redisplay it in the DataList.
clientnamelabel.Text = clientlabel
End If
End Sub