Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. DataBinder.Eval usage in Href [modified]

DataBinder.Eval usage in Href [modified]

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdatabasevisual-studio
16 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thenewbee
    wrote on last edited by
    #1

    I have problem with this line of code in my asp.net page. Its showing error. Can anyone help me? my Soucre Code is as follows:

    <asp:datagrid style="Z-INDEX: 101; POSITION: absolute; TOP: 136px; LEFT: 192px" id="DataGrid1"
    runat="server" AutoGenerateColumns="False">
    <Columns>
    <asp:TemplateColumn HeaderText="test">
    <ItemTemplate>
    <a href="www.yahoo.com?id=12" runat="server" id="h1">click</a>
    <asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1" Visible="False"></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:ButtonColumn Text="Button" HeaderText="edit" CommandName="ed"></asp:ButtonColumn>
    <asp:TemplateColumn HeaderText="Invoice No">
    <ItemTemplate>
    <a id ="h2" runat="server" href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid>

    Iam using VS 2003 When i changed to Design View i got the following error Could not open in Design view. Quote values differently inside a '<% ..."value"... %>' block.

    modified on Wednesday, January 6, 2010 1:23 AM

    M J A 3 Replies Last reply
    0
    • T thenewbee

      I have problem with this line of code in my asp.net page. Its showing error. Can anyone help me? my Soucre Code is as follows:

      <asp:datagrid style="Z-INDEX: 101; POSITION: absolute; TOP: 136px; LEFT: 192px" id="DataGrid1"
      runat="server" AutoGenerateColumns="False">
      <Columns>
      <asp:TemplateColumn HeaderText="test">
      <ItemTemplate>
      <a href="www.yahoo.com?id=12" runat="server" id="h1">click</a>
      <asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1" Visible="False"></asp:TextBox>
      </ItemTemplate>
      </asp:TemplateColumn>
      <asp:ButtonColumn Text="Button" HeaderText="edit" CommandName="ed"></asp:ButtonColumn>
      <asp:TemplateColumn HeaderText="Invoice No">
      <ItemTemplate>
      <a id ="h2" runat="server" href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>
      </ItemTemplate>
      </asp:TemplateColumn>
      </Columns>
      </asp:datagrid>

      Iam using VS 2003 When i changed to Design View i got the following error Could not open in Design view. Quote values differently inside a '<% ..."value"... %>' block.

      modified on Wednesday, January 6, 2010 1:23 AM

      M Offline
      M Offline
      meeram395
      wrote on last edited by
      #2

      It would be really helpful if you can provide the error message. Are you using any server control along with this? Can you provide full html source code?

      Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.

      T 1 Reply Last reply
      0
      • T thenewbee

        I have problem with this line of code in my asp.net page. Its showing error. Can anyone help me? my Soucre Code is as follows:

        <asp:datagrid style="Z-INDEX: 101; POSITION: absolute; TOP: 136px; LEFT: 192px" id="DataGrid1"
        runat="server" AutoGenerateColumns="False">
        <Columns>
        <asp:TemplateColumn HeaderText="test">
        <ItemTemplate>
        <a href="www.yahoo.com?id=12" runat="server" id="h1">click</a>
        <asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1" Visible="False"></asp:TextBox>
        </ItemTemplate>
        </asp:TemplateColumn>
        <asp:ButtonColumn Text="Button" HeaderText="edit" CommandName="ed"></asp:ButtonColumn>
        <asp:TemplateColumn HeaderText="Invoice No">
        <ItemTemplate>
        <a id ="h2" runat="server" href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>
        </ItemTemplate>
        </asp:TemplateColumn>
        </Columns>
        </asp:datagrid>

        Iam using VS 2003 When i changed to Design View i got the following error Could not open in Design view. Quote values differently inside a '<% ..."value"... %>' block.

        modified on Wednesday, January 6, 2010 1:23 AM

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        You cant mix databainding expressions and constant text in an attribute value, you have to concatenate it all in the databinding expression:

        Click Here

        NB: Pay special attention to the usage of single & double quotes in the above example.

        modified on Wednesday, January 6, 2010 4:24 AM

        T 1 Reply Last reply
        0
        • T thenewbee

          I have problem with this line of code in my asp.net page. Its showing error. Can anyone help me? my Soucre Code is as follows:

          <asp:datagrid style="Z-INDEX: 101; POSITION: absolute; TOP: 136px; LEFT: 192px" id="DataGrid1"
          runat="server" AutoGenerateColumns="False">
          <Columns>
          <asp:TemplateColumn HeaderText="test">
          <ItemTemplate>
          <a href="www.yahoo.com?id=12" runat="server" id="h1">click</a>
          <asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1" Visible="False"></asp:TextBox>
          </ItemTemplate>
          </asp:TemplateColumn>
          <asp:ButtonColumn Text="Button" HeaderText="edit" CommandName="ed"></asp:ButtonColumn>
          <asp:TemplateColumn HeaderText="Invoice No">
          <ItemTemplate>
          <a id ="h2" runat="server" href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>
          </ItemTemplate>
          </asp:TemplateColumn>
          </Columns>
          </asp:datagrid>

          Iam using VS 2003 When i changed to Design View i got the following error Could not open in Design view. Quote values differently inside a '<% ..."value"... %>' block.

          modified on Wednesday, January 6, 2010 1:23 AM

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          I think runat="server" is the culprit. Just remove it if you dont need. If you want runat="server" you can assign the href from the Server Side. I mean If it is inside an asp:Repeater to it inside ItemDataBound event.

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          My Latest Articles-->** Windows7 API Code Pack
          Simplify Code Using NDepend
          Basics of Bing Search API using .NET

          T J 2 Replies Last reply
          0
          • M meeram395

            It would be really helpful if you can provide the error message. Are you using any server control along with this? Can you provide full html source code?

            Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.

            T Offline
            T Offline
            thenewbee
            wrote on last edited by
            #5

            <asp:datagrid style="Z-INDEX: 101; POSITION: absolute; TOP: 136px; LEFT: 192px" id="DataGrid1"
            runat="server" AutoGenerateColumns="False">
            <Columns>
            <asp:TemplateColumn HeaderText="test">
            <ItemTemplate>
            <a href="www.yahoo.com?id=12" runat="server" id="h1">click</a>
            <asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1" Visible="False"></asp:TextBox>
            </ItemTemplate>
            </asp:TemplateColumn>
            <asp:ButtonColumn Text="Button" HeaderText="edit" CommandName="ed"></asp:ButtonColumn>
            <asp:TemplateColumn HeaderText="Invoice No">
            <ItemTemplate>
            <a id ="h2" runat="server" href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>
            </ItemTemplate>
            </asp:TemplateColumn>
            </Columns>
            </asp:datagrid>

            Iam using VS 2003 When i changed to Design View i got the following error Could not open in Design view. Quote values differently inside a '<% ..."value"... %>' block.

            1 Reply Last reply
            0
            • J J4amieC

              You cant mix databainding expressions and constant text in an attribute value, you have to concatenate it all in the databinding expression:

              Click Here

              NB: Pay special attention to the usage of single & double quotes in the above example.

              modified on Wednesday, January 6, 2010 4:24 AM

              T Offline
              T Offline
              thenewbee
              wrote on last edited by
              #6

              Sorry i misplaced the code Here is my full code

              <asp:datagrid style="Z-INDEX: 101; POSITION: absolute; TOP: 136px; LEFT: 192px" id="DataGrid1"
              runat="server" AutoGenerateColumns="False">
              <Columns>
              <asp:TemplateColumn HeaderText="test">
              <ItemTemplate>
              <a href="www.yahoo.com?id=12" runat="server" id="h1">click</a>
              <asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1" Visible="False"></asp:TextBox>
              </ItemTemplate>
              </asp:TemplateColumn>
              <asp:ButtonColumn Text="Button" HeaderText="edit" CommandName="ed"></asp:ButtonColumn>
              <asp:TemplateColumn HeaderText="Invoice No">
              <ItemTemplate>
              <a id ="h2" runat="server" href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>
              </ItemTemplate>
              </asp:TemplateColumn>
              </Columns>
              </asp:datagrid>

              Iam using VS 2003 When i changed to Design View i got the following error Could not open in Design view. Quote values differently inside a '<% ..."value"... %>' block.

              J 1 Reply Last reply
              0
              • A Abhishek Sur

                I think runat="server" is the culprit. Just remove it if you dont need. If you want runat="server" you can assign the href from the Server Side. I mean If it is inside an asp:Repeater to it inside ItemDataBound event.

                Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                My Latest Articles-->** Windows7 API Code Pack
                Simplify Code Using NDepend
                Basics of Bing Search API using .NET

                T Offline
                T Offline
                thenewbee
                wrote on last edited by
                #7

                <asp:datagrid style="Z-INDEX: 101; POSITION: absolute; TOP: 136px; LEFT: 192px" id="DataGrid1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateColumn HeaderText="test"> <ItemTemplate> <a href="www.yahoo.com?id=12" runat="server" id="h1">click</a> <asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1" Visible="False"></asp:TextBox> </ItemTemplate> </asp:TemplateColumn> <asp:ButtonColumn Text="Button" HeaderText="edit" CommandName="ed"></asp:ButtonColumn> <asp:TemplateColumn HeaderText="Invoice No"> <ItemTemplate> <a id ="h2" runat="server" href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:datagrid> Iam using VS 2003 When i changed to Design View i got the following error Could not open in Design view. Quote values differently inside a '<% ..."value"... %>' block.

                1 Reply Last reply
                0
                • T thenewbee

                  Sorry i misplaced the code Here is my full code

                  <asp:datagrid style="Z-INDEX: 101; POSITION: absolute; TOP: 136px; LEFT: 192px" id="DataGrid1"
                  runat="server" AutoGenerateColumns="False">
                  <Columns>
                  <asp:TemplateColumn HeaderText="test">
                  <ItemTemplate>
                  <a href="www.yahoo.com?id=12" runat="server" id="h1">click</a>
                  <asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1" Visible="False"></asp:TextBox>
                  </ItemTemplate>
                  </asp:TemplateColumn>
                  <asp:ButtonColumn Text="Button" HeaderText="edit" CommandName="ed"></asp:ButtonColumn>
                  <asp:TemplateColumn HeaderText="Invoice No">
                  <ItemTemplate>
                  <a id ="h2" runat="server" href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>
                  </ItemTemplate>
                  </asp:TemplateColumn>
                  </Columns>
                  </asp:datagrid>

                  Iam using VS 2003 When i changed to Design View i got the following error Could not open in Design view. Quote values differently inside a '<% ..."value"... %>' block.

                  J Offline
                  J Offline
                  J4amieC
                  wrote on last edited by
                  #8

                  Did you actually read my answer? :wtf:

                  T 1 Reply Last reply
                  0
                  • A Abhishek Sur

                    I think runat="server" is the culprit. Just remove it if you dont need. If you want runat="server" you can assign the href from the Server Side. I mean If it is inside an asp:Repeater to it inside ItemDataBound event.

                    Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                    My Latest Articles-->** Windows7 API Code Pack
                    Simplify Code Using NDepend
                    Basics of Bing Search API using .NET

                    J Offline
                    J Offline
                    J4amieC
                    wrote on last edited by
                    #9

                    Abhishek Sur wrote:

                    I think runat="server" is the culprit

                    No, really its not!

                    Abhishek Sur wrote:

                    you can assign the href from the Server Side. I mean If it is inside an asp:Repeater to it inside ItemDataBound event.

                    Why? Thats just 10x more complicated than expressing it as an attribute.

                    A 1 Reply Last reply
                    0
                    • J J4amieC

                      Abhishek Sur wrote:

                      I think runat="server" is the culprit

                      No, really its not!

                      Abhishek Sur wrote:

                      you can assign the href from the Server Side. I mean If it is inside an asp:Repeater to it inside ItemDataBound event.

                      Why? Thats just 10x more complicated than expressing it as an attribute.

                      A Offline
                      A Offline
                      Abhishek Sur
                      wrote on last edited by
                      #10

                      J4amieC wrote:

                      Why? Thats just 10x more complicated than expressing it as an attribute.

                      Yes.. Event if it is complicated, but ASP.NET is meant to deal with this events. It is better to handle server controls in the server and client control in the designer. I generally dont mix both in designer. Well, its upon the choice though.. ;)

                      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                      My Latest Articles-->** Windows7 API Code Pack
                      Simplify Code Using NDepend
                      Basics of Bing Search API using .NET

                      J 1 Reply Last reply
                      0
                      • A Abhishek Sur

                        J4amieC wrote:

                        Why? Thats just 10x more complicated than expressing it as an attribute.

                        Yes.. Event if it is complicated, but ASP.NET is meant to deal with this events. It is better to handle server controls in the server and client control in the designer. I generally dont mix both in designer. Well, its upon the choice though.. ;)

                        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                        My Latest Articles-->** Windows7 API Code Pack
                        Simplify Code Using NDepend
                        Basics of Bing Search API using .NET

                        J Offline
                        J Offline
                        J4amieC
                        wrote on last edited by
                        #11

                        Abhishek Sur wrote:

                        It is better to handle server controls in the server and client control in the designer

                        But the markup is also dealt with by the server:confused:

                        A 1 Reply Last reply
                        0
                        • J J4amieC

                          Did you actually read my answer? :wtf:

                          T Offline
                          T Offline
                          thenewbee
                          wrote on last edited by
                          #12

                          href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a> Here i havent used the concatenation but i have the problem with the quotation marks.

                          J 1 Reply Last reply
                          0
                          • T thenewbee

                            href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a> Here i havent used the concatenation but i have the problem with the quotation marks.

                            J Offline
                            J Offline
                            J4amieC
                            wrote on last edited by
                            #13

                            Seeing as you cant be bothered to read my answer, i cant be bothered to retype it, so i'll jusdt copy/paste from my answer

                            J4amieC wrote:

                            <a runat="server" id="h2" href='<%# "frmViewInvoiceDetails.aspx?invoiceID=" + DataBinder.Eval(Container.DataItem, "firstname")%>'> NB: Pay special attention to the usage of single & double quotes in the above example.

                            T 1 Reply Last reply
                            0
                            • J J4amieC

                              Seeing as you cant be bothered to read my answer, i cant be bothered to retype it, so i'll jusdt copy/paste from my answer

                              J4amieC wrote:

                              <a runat="server" id="h2" href='<%# "frmViewInvoiceDetails.aspx?invoiceID=" + DataBinder.Eval(Container.DataItem, "firstname")%>'> NB: Pay special attention to the usage of single & double quotes in the above example.

                              T Offline
                              T Offline
                              thenewbee
                              wrote on last edited by
                              #14

                              Ok i understood that but can u plz help me to give proper quotation for the below code href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>

                              J 1 Reply Last reply
                              0
                              • T thenewbee

                                Ok i understood that but can u plz help me to give proper quotation for the below code href= "frmViewInvoiceDetails.aspx?invoiceID=<%#DataBinder.Eval(Container,"DataItem.InvoiceID")%>">Click Here</a>

                                J Offline
                                J Offline
                                J4amieC
                                wrote on last edited by
                                #15

                                That code will never work - once again i'll copy from my original answer (this is getting boring) "You cant mix databainding expressions and constant text in an attribute value, you have to concatenate it all in the databinding expression:"

                                1 Reply Last reply
                                0
                                • J J4amieC

                                  Abhishek Sur wrote:

                                  It is better to handle server controls in the server and client control in the designer

                                  But the markup is also dealt with by the server:confused:

                                  A Offline
                                  A Offline
                                  Abhishek Sur
                                  wrote on last edited by
                                  #16

                                  I know... It is actually parse through the marker during Page Initialization.... But I think those events are meant to handle those, so why do we avoid them and make all those unnecessary adjustments in the Markup. I always like clean html in the designer with Server Controls in place as well.. It is true, that sometimes I need to do those classic ASP style Server tags in designer, but I do like avoiding those. We create Server controls to have better grip of server side (which is the main motive of ASP.NET) which is absent in the Classic ASP where we always need to write Server Tags in between htmls. For instance we can easily write : <asp:Label runat="server" Id="lbl" Text="<%=this.X %>"></asp:Label> (infact it will render nothing in the page) but we dont do, rather we use Page_Load and then set lbl.Text = this.X; Anyways, some like to write more and more Servertags within html, but personally I always like to handle them from codebehind, if it is avoidable. :):thumbsup:

                                  Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                                  My Latest Articles-->** Windows7 API Code Pack
                                  Simplify Code Using NDepend
                                  Basics of Bing Search API using .NET

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups