Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    89
    Thanks
    2
    Thanked 0 Times in 0 Posts

    HyperLink with Multiple Querystring Values

    Hello,

    I have a datagrid below and I'm trying to add a column that contains a hyperlink that will pass two querystring values, buts its not working.

    heres the code

    Code:
            <asp:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None">
                <Columns>
                    <asp:BoundColumn DataField="ID" HeaderText="ID" Visible="False"></asp:BoundColumn>
                    <asp:BoundColumn DataField="BatchDate" DataFormatString="{0:d}" HeaderText="Batch Date"></asp:BoundColumn>
                    <asp:BoundColumn DataField="JTTransDate" DataFormatString="{0:d}" HeaderText="Cashin Date"></asp:BoundColumn>
                    <asp:BoundColumn DataField="USaccountNo" HeaderText="Account No."></asp:BoundColumn>
                    <asp:BoundColumn DataField="ID" HeaderText="Cashin Ref. No."></asp:BoundColumn>
                    <asp:BoundColumn DataField="USfirstname" HeaderText="First Name"></asp:BoundColumn>
                    <asp:BoundColumn DataField="USsurname" HeaderText="Last Name"></asp:BoundColumn>
                    <asp:BoundColumn DataField="Currency" HeaderText="Currency"></asp:BoundColumn>
                    <asp:BoundColumn DataField="Amount" HeaderText="Amount"></asp:BoundColumn>
                    <asp:BoundColumn DataField="JTDescription" HeaderText="Payment Type"></asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="Status">
                        <ItemTemplate>
                            &nbsp;
                            <asp:DropDownList ID="DropDownList1" runat="server"  >
                                <asp:ListItem Selected="True" Value="S">Select...</asp:ListItem>
                                <asp:ListItem Value="H">On Hold</asp:ListItem>
                                <asp:ListItem Value="C">Reject</asp:ListItem>
                                <asp:ListItem Value="U">Update</asp:ListItem>
                            </asp:DropDownList>
                        </ItemTemplate>
                        <EditItemTemplate>
                            
                        </EditItemTemplate>
                    </asp:TemplateColumn>             
                    <asp:TemplateColumn>
                    <asp:HyperLink runat="server" NavigateUrl="<%# "view_record.aspx?id=" + Container.DataItem("ID") + "&JT=" + Container.DataItem("JTDescription") %>">view / edit</asp:HyperLink>
                    </asp:TemplateColumn>
    
                </Columns>
                <FooterStyle BackColor="#3386AE" Font-Bold="True" ForeColor="White" />
                <EditItemStyle BackColor="#2461BF" />
                <SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <AlternatingItemStyle BackColor="White" />
                <ItemStyle BackColor="#EFF3FB" />
                <HeaderStyle BackColor="#3386AE" Font-Bold="True" ForeColor="White" />
                
            </asp:DataGrid>

    the line...

    <asp:HyperLink runat="server" NavigateUrl="<%# "view_record.aspx?id=" + Container.DataItem("ID") + "&JT=" + Container.DataItem("JTDescription") %>">view / edit</asp:HyperLink>

    ...is where I am trying to create the link. The errors I get are...

    "element hypertag is not a known element"
    "Code blocks are not supported in this context"
    "The server tag is not well formed"

    any thoughts?

    Thank you.

  • #2
    New Coder
    Join Date
    Sep 2005
    Posts
    89
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I've changed it arround a bit to the following...

    Code:
     <asp:TemplateColumn >
              <ItemTemplate>                 
                    <asp:HyperLink Id="lnkEdit" runat="server" NavigateUrl='<%# "view_record.aspx?id=" + Container.DataItem("ID") + "&JT=" + Container.DataItem("JTDescription") %>'>view / edit</asp:HyperLink>
               </ItemTemplate>
    </asp:TemplateColumn>

    and it gave me the following error...


    System.Web.UI.WebControls.DataGridItem.DataItem' is a 'property' but is used like a 'method'

  • #3
    New Coder
    Join Date
    Sep 2005
    Posts
    89
    Thanks
    2
    Thanked 0 Times in 0 Posts
    fixed it

    <asp:HyperLink runat="server" NavigateUrl=<%# "view_record.aspx?id=" + DataBinder.Eval(Container.DataItem, "ID") + "&JT=" + DataBinder.Eval(Container.DataItem, "JTDescription") %>>view / edit</asp:HyperLink>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •