|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using if on ASPX-side instead of in code behindthree script-sections. <% if (true) { %> <%# MyLogic.GetName( DataBinder.GetPropertyValue((List<MyInfo>) Container.DataItem)[0], "PropName")) %> <% } %> I'd like to make it into a single one, similarly to the example below. The name Container isn't recognized, the computer tells me, though. <% if (true) { MyLogic.GetName( DataBinder.GetPropertyValue(((List<MyInfo>) Container.DataItem)[0], "PropName")); } %> What do i miss? What's the exact syntax here? (I know that the best choice is to do that from code behind and i intend to solve it that way. However, i'm curious of how to make the above work without code behind. It IS doable, right?) -- Regards K Viltersten ---------------------------------------- May all spammers die an agonizing death; have no burial places; their souls be chased by demons in Gehenna from one room to another for all eternity and beyond.
Show quote
Hide quote
"K Viltersten" <t***@viltersten.com> schrieb im Newsbeitrag Hi K, ;)news:7bj5rfF23ofibU1@mid.individual.net... >I have the following script consisting of three script-sections. > > <% if (true) { %> > <%# MyLogic.GetName( > DataBinder.GetPropertyValue((List<MyInfo>) > Container.DataItem)[0], "PropName")) %> > <% } %> > > I'd like to make it into a single one, similarly > to the example below. The name Container isn't > recognized, the computer tells me, though. > > <% if (true) { MyLogic.GetName( > DataBinder.GetPropertyValue(((List<MyInfo>) > Container.DataItem)[0], "PropName")); > } %> > > What do i miss? What's the exact syntax here? > > (I know that the best choice is to do that from > code behind and i intend to solve it that way. > However, i'm curious of how to make the above > work without code behind. It IS doable, right?) > > -- > Regards > K Viltersten > ---------------------------------------- > May all spammers die an agonizing death; > have no burial places; their souls be > chased by demons in Gehenna from one room > to another for all eternity and beyond. > "Container" is only available in <%# - blocks (within a data binding expression). But in these, you can't use the if-statement. You are only allowed to use expressions that returns a value. So there's no chance to combine them this way... but you can use "? :"- or a codebehind member instead (if it helps) http://msdn.microsoft.com/en-us/library/bda9bbfx(VS.71).aspx Sorry for my bad english... Greets, Wolfgang Kluge http://gehirnwindung.de/ http://klugesoftware.de/ Hi,
I am sendu an recruiter from E*pro. Nice to have a glance every day in this community and its people. Happy to observe its concept and postings. I am working with a recruiting firm and recruiting people in various IT,Accounting,ITES and other domains. I need updated resume from people in Various parts of US. I can help them in getting a better oppurtinity in any field of their aspiration. Mail ur updated CV to: nse***@eprocorp.com Warm Regards, N.Sendu. E*pro. "K Viltersten" <t***@viltersten.com> wrote in news:7bj5rfF23ofibU1 @mid.individual.net:Show quoteHide quote > I have the following script consisting of Container is a special construct when a control is data bound. It is > three script-sections. > > <% if (true) { %> > <%# MyLogic.GetName( > DataBinder.GetPropertyValue((List<MyInfo>) > Container.DataItem)[0], "PropName")) %> > <% } %> > > I'd like to make it into a single one, similarly > to the example below. The name Container isn't > recognized, the computer tells me, though. > > <% > if (true) { > MyLogic.GetName( > DataBinder.GetPropertyValue(((List<MyInfo>) > Container.DataItem)[0], "PropName")); > } > %> > > What do i miss? What's the exact syntax here? > > (I know that the best choice is to do that from > code behind and i intend to solve it that way. > However, i'm curious of how to make the above > work without code behind. It IS doable, right?) > normally used to declaratively bind a particular data column to a control that binds many elements, like a Repeater, DataList, GridView, etc. And, when you do this, you use a special syntax: <%# %> The # here is important, although I forget all of the specifics of this. At one time, it was dubbed simple data binding, whereas using the events was complex data binding. Once you move to <% %>, you are essentially coding as if you are using code behind. There are two ways to solve this that I can think of off hand: 1. To simple bind, use the element only. Then properly trim out the ! true (false) elements. This is essentially altering the dataset, linq objects (etc) prior to bind 2. Use the row binding event to determine whether to display or not. I am not sure you can easily mix the DataBinder logic with code as you have, or at least not easily, as the parser would not recognize the mixture. -- Show quoteHide quoteGregory A. Beamer MVP; MCP: +I, SE, SD, DBA Twitter: @gbworld Blog: http://gregorybeamer.spaces.live.com ****************************************** | Think outside the box! | ****************************************** Hi,
I am sendu an recruiter from E*pro. Nice to have a glance every day in this community and its people. Happy to observe its concept and postings. I am working with a recruiting firm and recruiting people in various IT,Accounting,ITES and other domains. I need updated resume from people in Various parts of US. I can help them in getting a better oppurtinity in any field of their aspiration. Mail ur updated CV to: nse***@eprocorp.com Warm Regards, N.Sendu. E*pro. Hi,
I am sendu an recruiter from E*pro. Nice to have a glance every day in this community and its people. Happy to observe its concept and postings. I am working with a recruiting firm and recruiting people in various IT,Accounting,ITES and other domains. I need updated resume from people in Various parts of US. I can help them in getting a better oppurtinity in any field of their aspiration. Mail ur updated CV to: nse***@eprocorp.com Warm Regards, N.Sendu. E*pro.
Other interesting topics
restrict number of users
Calling Application_Start After Worker Process is Recycled Page refresh - Alternative to using frames á ÇáÅÓáÇã Úä ÇáÅÑåÇÈ¿ Redirect To Login Page - Forms Authentication Server.ScriptTimeout not being observed? VB.Net Developer, Houstan TX, Duration: 6months, ONLY Green Card / (1-140 & EAD approved) How can the Login control stop authenticating? Javascript question American and European Converted from Christianity to ISLAM |
|||||||||||||||||||||||