[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Gridview and querystring

Posted on 2009-12-16
10
Medium Priority
?
600 Views
Last Modified: 2012-05-08
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
Comment
Question by:Isaac
  • 6
  • 3
10 Comments
 
LVL 6

Expert Comment

by:Ramone_Hamilton
ID: 26063863
Doesn't Eval return object?  Does <% Eval("Assigned") as string %> work?  What error are you getting?
0
 
LVL 5

Author Comment

by:Isaac
ID: 26063925
Error Creating Control - GridView2
Literal content ('asp:HyperLinkField NavigateUrl=editAttorney.aspx?mi=") is not allowed within a 'System.Web.UI.WebControls.DataControlFieldConllection'.
0
 
LVL 6

Expert Comment

by:Ramone_Hamilton
ID: 26063964
Try NavigateUrl = 'editAttorney.aspx?mi= <% Eval("ASSIGNED") as string %>'
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Author Comment

by:Isaac
ID: 26064024
That's what I tried and to get the error
0
 
LVL 6

Expert Comment

by:Ramone_Hamilton
ID: 26064111
How about: NavigateUrl = 'editAttorney.aspx?mi= <%# Eval("ASSIGNED") as string %>'
0
 
LVL 6

Expert Comment

by:Ramone_Hamilton
ID: 26064112
Sorry I forgot the # sound last time.
0
 
LVL 6

Expert Comment

by:Ramone_Hamilton
ID: 26064184
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
 
LVL 5

Author Comment

by:Isaac
ID: 26064865
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
 
LVL 18

Accepted Solution

by:
Rajar Ahmed earned 2000 total points
ID: 26065245
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
 
LVL 6

Expert Comment

by:Ramone_Hamilton
ID: 26065571
Wow I forgot the DataNavigateUrlFields.  Can't get any better than that.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question