Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Moderators
Posted

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

Visit...Bassic Software
  • 2 weeks later...
Posted

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?

Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...