Converting to a variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DaveRook
    New Member
    • Jul 2007
    • 147

    Converting to a variable

    Hi

    I can't do this. I have spent over a week looking/reading books/internet and have got no where.

    I would like to apply an if else statement to an <%# Eval

    I would like to say:

    <%#
    if ((DataBinder.Ev al(Container.Da taItem, "Pn")) !="" )
    {
    string var_Pn = ((DataBinder.Ev al(Container.Da taItem, "Pn")).ToString ())
    response.write = "Find some thing else";
    }

    %>

    I have posted similar before, but have gotten no where and am quite desperate for help.
  • DaveRook
    New Member
    • Jul 2007
    • 147

    #2
    Converting to a variable

    Hi

    I can't do this. I have spent over a week looking/reading books/internet and have got no where.

    I would like to apply an if else statement to an <%# Eval

    I would like to say:

    Code:
    <%#
    if ((DataBinder.Eval(Container.DataItem, "Pn")) !="" )
    {
        string var_Pn = ((DataBinder.Eval(Container.DataItem, "Pn")).ToString())
        response.write = "Find some thing else";
    }
    %>
    I have posted similar before, but have gotten no where and am quite desperate for help.

    Thanks

    Dave

    Comment

    • CyberSoftHari
      Recognized Expert Contributor
      • Sep 2007
      • 488

      #3
      You can use like
      [CODE=cpp]<%
      Dim myNum
      myNum = 6
      If myNum = 6 The
      {
      //True part here
      Response.Write( "Variable myNum = 6")
      }
      else
      {
      //False part here
      Response.Write( "Variable myNum = 6")
      }
      %>[/CODE]
      Note: You cannot expect your reply within some time. consider time zones of different places and this is an international community.

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Originally posted by CyberSoftHari
        You can use like
        [CODE=cpp]<%
        Dim myNum
        myNum = 6
        If myNum = 6 The
        {
        //True part here
        Response.Write( "Variable myNum = 6")
        }
        else
        {
        //False part here
        Response.Write( "Variable myNum = 6")
        }
        %>[/CODE]
        Note: You cannot expect your reply within some time. consider time zones of different places and this is an international community.
        I don't think that this will work inside a Repeater or Datalist. He was using the <%# tags.

        I'm not sure that this is possible. What I've done in the past is use a Literal control, and use my code behind to fill it with a for loop, and the results are just like a repeater.

        Comment

        • CyberSoftHari
          Recognized Expert Contributor
          • Sep 2007
          • 488

          #5
          I am unable to understand his topic and the query asked inside (I am not in flow with previous OP’s post), better he should give appropriate topic.
          [CODE=html]<body>
          <form id="form1" runat="server">
          <asp:ScriptMana ger ID="ScriptManag er1" runat="server" />
          <div>
          <asp:UpdatePane l ID="UpdatePanel 1" runat="server">
          <ContentTemplat e>
          <% for (int i = 0; i <= 3; i++)
          { %>
          <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
          <%
          if (TextBox1.Text == "")
          {
          TextBox1.Text = "MyName";
          }
          else
          {
          TextBox1.Text = "YourName";
          }
          } %>
          </ContentTemplate >
          </asp:UpdatePanel >
          &nbsp;</div>
          <asp:Button ID="Button1" runat="server" Text="Button" />
          </form>
          </body>[/CODE]
          Above sample i tested and I never found any difficult or error to run. Thanks to make myself a conformation.

          DaveRook, Give appropriate topic and explain your problem in detail. You have to check your code tags. starting with <%# and Closing with %>
          Last edited by CyberSoftHari; Jun 6 '08, 03:15 PM. Reason: Typo...

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Threads Merged. Please do not double post your questions, it is against the posting guidelines.

            MODERATOR

            Originally posted by insertAlias
            What I've done in the past is use a Literal control, and use my code behind to fill it with a for loop, and the results are just like a repeater.
            Yeah, I am a big fan of NOT doing anything inside <%# tags. Control code is for code files, designer code is for design files.
            I recomend switching to using backend code to controls things, makes life easier when you need to manipulate the data. Divide and conquer and all that.

            Comment

            • CyberSoftHari
              Recognized Expert Contributor
              • Sep 2007
              • 488

              #7
              I agree and never prefer <%{Code}%> this code tags inside Html, but it is hard to OP for recode everything in his project. So pointing that way will be simplest to him/her.

              Comment

              Working...