...

View Full Version : HyperLink with Multiple Querystring Values



fogofogo
06-29-2007, 11:21 AM
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


<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
06-29-2007, 02:53 PM
I've changed it arround a bit to the following...


<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
06-29-2007, 03:48 PM
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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum