Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-29-2007, 11:21 AM   PM User | #1
fogofogo
New Coder

 
Join Date: Sep 2005
Posts: 89
Thanks: 2
Thanked 0 Times in 0 Posts
fogofogo is an unknown quantity at this point
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.
fogofogo is offline   Reply With Quote
Old 06-29-2007, 02:53 PM   PM User | #2
fogofogo
New Coder

 
Join Date: Sep 2005
Posts: 89
Thanks: 2
Thanked 0 Times in 0 Posts
fogofogo is an unknown quantity at this point
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'
fogofogo is offline   Reply With Quote
Old 06-29-2007, 03:48 PM   PM User | #3
fogofogo
New Coder

 
Join Date: Sep 2005
Posts: 89
Thanks: 2
Thanked 0 Times in 0 Posts
fogofogo is an unknown quantity at this point
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>
fogofogo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:50 AM.


Advertisement
Log in to turn off these ads.