Solved

C# Anchor tag

Posted on 2004-08-06
3
2,641 Views
Last Modified: 2011-10-03
Hi all

I am new to C# i am using repeater control to display data the code is as follow. I need to assign  customerid in the anchor tag can anyone help me.


<tr><td colspan=4><ASP:Repeater id="MyRepeater" runat="server">
      <HeaderTemplate>
         <table width=600 border=1 frame="void" bordercolordark="#FFFFFF" bordercolorlight="#cccccc" rules="rows">
            <tr class='barbg' align=left >
               <th class="titlehead">
                  &nbsp;Name
               </th>
               <th class="titlehead">
                  &nbsp;Telephone
               </th >
               <th class="titlehead">
                 &nbsp; Fax
               </th >
               <th class="titlehead">
                  &nbsp;Contact Name
               </th>
               <th class="titlehead">
                  &nbsp;Contacts
               </th>
             
            </tr>
      </HeaderTemplate>
            
            
      <ItemTemplate>
            
            <tr class='colhead' >
               <td width=150>
                  <%# DataBinder.Eval(Container.DataItem, "customername") %>
               </td>
               <td width=100>
                  <%# DataBinder.Eval(Container.DataItem,"phone") %>
               </td>
               <td width=100>
                  <%# DataBinder.Eval(Container.DataItem, "fax") %>
               </td>
               <td width=100>
                  <%# DataBinder.Eval(Container.DataItem, "Contactname") %>
               </td>
                <td width=100>
                 <a id="link1" runat="server" HRef="customercontact.aspx?custid="><%# DataBinder.Eval(Container.DataItem, "Contactname") %></a>
               </td>
            </tr>
           
      </ItemTemplate>
     
            
      <FooterTemplate>
      <tr class='colhead' >
               <td colspan='4'>&nbsp;</td>
                 
            </tr>
         </Table>
      </FooterTemplate>
   </ASP:Repeater></td></tr>
     
      
thanks
0
Comment
Question by:surya_madhavi
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
nhewitt21 earned 50 total points
ID: 11734784
try replacing:
<a id="link1" runat="server" HRef="customercontact.aspx?custid="><%# DataBinder.Eval(Container.DataItem, "Contactname") %></a>

with:
<asp:Label id="label_lnk" text='<%#"<a id=\"link1\" runat=\"server\" href=\"customercontact.aspx?custid=" + (DataBinder.Eval(Container.DataItem,"Contactname").ToString()) + "\">" + (DataBinder.Eval(Container.DataItem,"Contactname").ToString())  + "</a>"%>'/>

That should do the trick.
0
 

Author Comment

by:surya_madhavi
ID: 11734898
Hi

thank you it worked.
0
 
LVL 3

Expert Comment

by:nhewitt21
ID: 11734966
No problem, glad it worked for you
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question