Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

<asp:HyperLink not evaluating the column in DataGridView

Posted on 2006-11-07
8
658 Views
Last Modified: 2008-01-16
Hi,

I have the following inside of a DataGridView:

                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="DealEntry.aspx?TradeId='<%#Eval('TradeId')%>'"
                            Text='Select'></asp:HyperLink>


When it passes it to the DealEntry it does not evaluate it.  Instead I get the following URL:

http://localhost/Test/DealEntry.aspx?TradeId='<%#Eval('TradeId')%>'

Thanks
0
Comment
Question by:techhound
  • 4
  • 4
8 Comments
 
LVL 58

Expert Comment

by:amit_g
ID: 17891042
Like this ...

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='DealEntry.aspx?TradeId=<%#Eval("TradeId")%>' Text='Select'></asp:HyperLink>
0
 

Author Comment

by:techhound
ID: 17891123
Thanks for the information.

I copied your example directly into my code and it did not work.  It gives this as the URL:

http://localhost/Test/DealEntry.aspx?TradeId=<%#Eval("TradeId")%>

It doesn't seem to evaluate the column.

Thanks
0
 
LVL 58

Expert Comment

by:amit_g
ID: 17891194
Is everything else in the datagrid bound? Could you please show us the whole DataGrid tag. Also what version of .Net are you using? This would work in 2.0 only. For 1.0 and 1.1 you have to use Databinder.Eval(Container.DataItem, "TradedId")
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 

Author Comment

by:techhound
ID: 17891301
Hi, I am using .NET 2.0

Here is the Grid:

               <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
            AutoGenerateColumns="False" CssClass="MasterGrid" DataSourceID="SqlDataSource1" Width="850px" BorderStyle="None" CellPadding="3" GridLines="Vertical" BackColor="White" BorderColor="#999999" BorderWidth="1px" HorizontalAlign="Left" OnRowCommand="GridView1_RowCommand">
            <FooterStyle CssClass="FooterStyle" ForeColor="Black" BackColor="#CCCCCC" />
            <RowStyle CssClass="RowStyle" Font-Names="Tahoma" Font-Size="9pt" BackColor="#EEEEEE" ForeColor="Black" />
            <EditRowStyle CssClass="RowFormat" />
            <PagerStyle CssClass="PagerStyle" Font-Names="Century" Font-Size="10pt" BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
            <AlternatingRowStyle BackColor="Gainsboro" />
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='DealEntry.aspx?TradeId=<%#Eval("TradeId")%>' Text='Select'></asp:HyperLink>                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="TradeId" HeaderText="Trade Id" InsertVisible="False" SortExpression="TradeId" />
                <asp:BoundField DataField="CreditSpread" HeaderText="Credit Spread" SortExpression="CreditSpread" />
                <asp:BoundField DataField="Protection" HeaderText="Protection" SortExpression="Protection" />
                <asp:BoundField DataField="TradeDate" HeaderText="Trade Date" SortExpression="TradeDate" />
                <asp:TemplateField HeaderText="CounterPartyId" SortExpression="CounterPartyId">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="CounterPartyDataSource"
                            DataTextField="counterParty" DataValueField="id">
                        </asp:DropDownList><asp:SqlDataSource ID="CounterPartyDataSource" runat="server"
                            ConnectionString="<%$ ConnectionStrings:WarehouseConnectionString1 %>" SelectCommand="SELECT [id], [counterParty] FROM [CounterParties]">
                        </asp:SqlDataSource>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("CounterPartyId") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="TradeNotional" HeaderText="TradeNotional" SortExpression="TradeNotional" />
            </Columns>
            <EmptyDataTemplate>
                Please Select Reference Entity!
            </EmptyDataTemplate>
        </asp:GridView>
0
 
LVL 58

Expert Comment

by:amit_g
ID: 17891487
To debug change

                <asp:TemplateField>
                    <ItemTemplate>
                                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='DealEntry.aspx?TradeId=<%#Eval("TradeId")%>' Text='Select'></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>

to

                <asp:TemplateField>
                    <ItemTemplate>
                            TradeId : <%# Eval("TradeId") %><br>
                            <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='DealEntry.aspx?TradeId=<%#Eval("TradeId")%>' Text='Select'></asp:HyperLink>                    
                    </ItemTemplate>
                </asp:TemplateField>

What do you get? How many rows do you get?
0
 

Author Comment

by:techhound
ID: 17891549
Hi,

When I do that I get the proper Trade Id. It doesn't seem to evaluate it correctly in the Hyperlink though.  Very strange!
0
 
LVL 58

Accepted Solution

by:
amit_g earned 500 total points
ID: 17892336
Do it like this ...

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "DealEntry.aspx?TradeId=" & Eval("TradeId") %>' Text='Select'></asp:HyperLink>

If you are using C# use + instead of &.
0
 

Author Comment

by:techhound
ID: 17892372
So Cool! That Worked! Awesome and Many Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Want the count number from this QUery 2 54
Html CheckBox obtain Its Value 5 27
html Uncheck Checkbox 2 25
Adjust an existing ASP Query 45 16
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

856 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