• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 601
  • Last Modified:

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!
<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>

Open in new window

0
Isaac
Asked:
Isaac
  • 6
  • 3
1 Solution
 
Ramone_HamiltonCommented:
Doesn't Eval return object?  Does <% Eval("Assigned") as string %> work?  What error are you getting?
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
Error Creating Control - GridView2
Literal content ('asp:HyperLinkField NavigateUrl=editAttorney.aspx?mi=") is not allowed within a 'System.Web.UI.WebControls.DataControlFieldConllection'.
0
 
Ramone_HamiltonCommented:
Try NavigateUrl = 'editAttorney.aspx?mi= <% Eval("ASSIGNED") as string %>'
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
IsaacSharePoint Client Side DeveloperAuthor Commented:
That's what I tried and to get the error
0
 
Ramone_HamiltonCommented:
How about: NavigateUrl = 'editAttorney.aspx?mi= <%# Eval("ASSIGNED") as string %>'
0
 
Ramone_HamiltonCommented:
Sorry I forgot the # sound last time.
0
 
Ramone_HamiltonCommented:
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"
 />

Open in new window

0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
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.
0
 
Rajar AhmedConsultantCommented:
Multiple Query string Can be Passed by using this ....

 
 <asp:GridView ID="GridView2" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" 
        CellPadding="3" CellSpacing="1" Font-Size="Small" 
        ForeColor="#333333" GridLines="None" HorizontalAlign="Center" PageSize="20" 
        Width="85%">
        <RowStyle BackColor="#EFF3FB" />
        <Columns>
            <asp:BoundField DataField="cvid" HeaderText="Initials" 
                SortExpression="ASSIGNED" />
            <asp:BoundField DataField="cvid" HeaderText="Last Name" 
                SortExpression="ASSIGNED_LAST_NAME" />
            <asp:BoundField DataField="cvid" HeaderText="First Name" 
                SortExpression="ASSIGNED_FIRST_NAME" />
            <asp:BoundField DataField="cvid" HeaderText="Middle Initials" 
                SortExpression="ASSIGNED_MI" />
           <asp:HyperLinkField DataNavigateUrlFields="id1,id2" DataNavigateUrlFormatString= "test.aspx?id1={0}&id2={1}" Text="View Products" /> 
        </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>

Open in new window

0
 
Ramone_HamiltonCommented:
Wow I forgot the DataNavigateUrlFields.  Can't get any better than that.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

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.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now