andycharger Posted November 24, 2003 Posted November 24, 2003 Im currently pulling a record from the database and populating some text boxes with the results via a datalist. However, what I want to do is say: If (one of my fields) = session("userid") then strVal = true else strVal = false end if This is so I can set the edit button to on or off because the user is the person who created the entry. Trouble is, im not sure how I show the variable on screen. In my datalist, I use <%# DataBinder.Eval(Container.DataItem, "id") %> Obviously ouside of the datalist, this does not work. So how do I call one of the values in the datalist and assign it to a variable? I have tried strFieldIWant = DataBinder.Eval(Container.DataItem, "id") But that does not work. Any ideas. Quote
Moderators Robby Posted November 24, 2003 Moderators Posted November 24, 2003 try this... <%# myServerFunction(Container.DataItem("id")) %> then in your code-behind.. public function myServerFunction(byval xID as integer) as String If (one of my fields) = xID then return "Something" else return "SomethingElse" end if end function Quote Visit...Bassic Software
andycharger Posted December 3, 2003 Author Posted December 3, 2003 Thanks for that. It seems to work on my local machine now but when I put it on the server that contains my Intranet, it tells me that: Compiler Error Message: BC30451: Name 'myServerFunction' is not declared. But my function IS in the code section of that page (. the .vb file) Any ideas? Quote
Moderators Robby Posted December 3, 2003 Moderators Posted December 3, 2003 Did you declare it as public in the base class of the aspx page? Quote Visit...Bassic Software
andycharger Posted December 3, 2003 Author Posted December 3, 2003 Base class? Do you mean the .vb page that is named the same as the .aspx page? i.e my page is called ithelpdesk.aspx and my code page is called ithelpdesk.aspx.vb If so, YES I did declare it as a Public Function. I copied it exactly as you wrote it but just asigned a variable to the sessionid. It looks exactly like this: Public Function myServerFunction(ByVal xID As Integer) As String Dim strName = Session("userid") If (strName) = xID Then Return "Something" Else Return "SomethingElse" End If End Function Any ideas? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.