|
-
Sep 24th, 2010, 02:57 PM
#1
Thread Starter
Lively Member
function & datalist
I have a function called selType that returns either "mc" or "car"
Then in my datalist i would like to check if the function returns "mc" it should output pName, else pNameFI from my db.
I need something like this..
Code:
<%# if selType="mc","pName","pNameFI") %>
But this don't work.. I don't know how to achieve this.. Can anyone help me?
-
Sep 24th, 2010, 03:14 PM
#2
Frenzied Member
Re: function & datalist
Any reason you are not doing this in code behind where you can just set the DataMember of the DataList after calling the function?
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Sep 24th, 2010, 03:25 PM
#3
Thread Starter
Lively Member
Re: function & datalist
I also get more data in my datalist than in my function.. That is just a part.. Is it possible to achieve this in my aspx file?
-
Sep 24th, 2010, 03:38 PM
#4
Re: function & datalist
"But this don't work.. " ... and that doesn't tell us the problem either. Did your arm fall off? or did you get toast? Saying something "doesn't work" with out any further information is akin to walking into the Doc's office and saying "it hurts".
If you are getting errors, there an error message and it should also point you at what line(s) are in error.
At this point, I'd be forced to guess what the problem is, but I'd assume not waste the time of either of us chasing a rabbit down a hole only to fine out that I wanted the badger in the next hole over.
-tg
-
Sep 24th, 2010, 03:59 PM
#5
Thread Starter
Lively Member
Re: function & datalist
Well well, i thought someone who have worked more with datalist than i have could point me in right direction without further explaining..
I based my try on this code i have used before that works:
Code:
<asp:CheckBox ID="CheckBox1" runat="server" Visible='<%# if(Eval("isFolder")="1","false","true") %>' />
<%#DataBinder.Eval(Container.DataItem, "pName")%>
From the above code i tried with this where i try to use both IF and a function, but i canät get it to work.
Code:
<%# if selType="mc","pName","pNameFI") %>
The error i get is : 'If' operator requires either two or three operands
Any ideas how the correct string would be?
-
Sep 25th, 2010, 03:46 AM
#6
Re: function & datalist
A couple of points...
First up, as tg pointed out, we are not mind readers, and although some people here have a lot of experience with ASP.Net, we need to know what it is you are trying to achieve before we can make suggestions.
Secondly, embedding server side script tags into your ASPX markup is not a great idea, and if I were to give one piece of advice, it would be to stay away from it. I would encourage you to have a look at this article:
http://www.codeguru.com/vb/gen/vb_mi...T-Web-Site.htm
Specifically page 4.
Gary
-
Sep 25th, 2010, 10:21 AM
#7
Re: function & datalist
That's what I'm talking about... the problem isn't your dataset... it's your code... I saw the problem, but figured it was a typo, so I didn't want to go down that rabbit hole if I'm after a badger...
You're not using the if function... you're actually using the If keyword. What you DO want is the If function, but you need to use an OPEN PARENTHESIS and a CLOSING PARENTHESIS... you got the closing one....
Code:
<%# if selType="mc","pName","pNameFI") %> 'compare with next line
<%# if (selType="mc","pName","pNameFI") %> 'see the difference?
-tg
-
Sep 27th, 2010, 01:23 AM
#8
Re: function & datalist
You should have got some indication of the problem on the client using the JavaScript console. What browser are you using? Each one has it's own way of bringing up the JavaScript console to help with debugging.
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|