Isaac
asked on
Gridview and querystring
I have a gridview that has 5 columns. The 5th column is an edit link.
How can I use one or more of the bound fields in the querystring?
The way I did it is not working:
<asp:HyperLinkField NavigateUrl="editAttorney. aspx?mi=<% Eval("Assigned") %>" Text="Edit" />
Thanks!
How can I use one or more of the bound fields in the querystring?
The way I did it is not working:
<asp:HyperLinkField NavigateUrl="editAttorney.
Thanks!
<asp:GridView ID="GridView2" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
DataSourceID="orclDataSource" CellPadding="3" CellSpacing="1" Font-Size="Small"
ForeColor="#333333" GridLines="None" HorizontalAlign="Center" PageSize="20"
Width="85%">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="ASSIGNED" HeaderText="Initials"
SortExpression="ASSIGNED" />
<asp:BoundField DataField="ASSIGNED_LAST_NAME" HeaderText="Last Name"
SortExpression="ASSIGNED_LAST_NAME" />
<asp:BoundField DataField="ASSIGNED_FIRST_NAME" HeaderText="First Name"
SortExpression="ASSIGNED_FIRST_NAME" />
<asp:BoundField DataField="ASSIGNED_MI" HeaderText="Middle Initials"
SortExpression="ASSIGNED_MI" />
<asp:HyperLinkField NavigateUrl="editAttorney.aspx" Text="Edit" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
Doesn't Eval return object? Does <% Eval("Assigned") as string %> work? What error are you getting?
ASKER
Error Creating Control - GridView2
Literal content ('asp:HyperLinkField NavigateUrl=editAttorney.a spx?mi=") is not allowed within a 'System.Web.UI.WebControls .DataContr olFieldCon llection'.
Literal content ('asp:HyperLinkField NavigateUrl=editAttorney.a
Try NavigateUrl = 'editAttorney.aspx?mi= <% Eval("ASSIGNED") as string %>'
ASKER
That's what I tried and to get the error
How about: NavigateUrl = 'editAttorney.aspx?mi= <%# Eval("ASSIGNED") as string %>'
Sorry I forgot the # sound last time.
I am telling you wrong, you are using a hyperLink, my previous methods would work with a bindable control like a label. You want to use the DataFormatUrl
<asp:HyperLinkField NavigateUrl="editAttorney.aspx" Text="Edit" DataNavigateUrlFormatString="editAttorney.aspx?mi={0}" DataTextField="ASSIGNED"
/>
ASKER
That's not working the way it should.
Now I get the value of "ASSIGNED" as a link in my edit column.
Basically the data in the table for "ASSIGNED" is rendered in the edit column.
Now I get the value of "ASSIGNED" as a link in my edit column.
Basically the data in the table for "ASSIGNED" is rendered in the edit column.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Wow I forgot the DataNavigateUrlFields. Can't get any better than that.