I'm working on a manager of sorts that allows certain employees to view the results of a survey customers take. I'm tracking the IP address of the customers that take the survey and displaying that ip address to the employees who can view the results. I'm using a gridview with an sqldatasource to extract the data out of the database and display it. What I would like to do is add a button or link that takes the IP address and appends it to a url of web site to track the location of the ip address on a map. I have already signed up for a serivce to do this but am unsure of how to code it.
Here is my Gridview
<asp:GridView ID="GVnewsletterManager" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="4" DataKeyNames="email_time" ForeColor="Black"
GridLines="Horizontal" Width="100%" PageSize="15">
<Columns>
<asp:BoundField DataField="email_time" HeaderText="Length of Email Subscription"
SortExpression="email_time" />
<asp:BoundField DataField="reason" HeaderText="Reason for Unsubscribe"
SortExpression="reason" />
<asp:BoundField DataField="other" HeaderText="Other Reason"
SortExpression="other" />
<asp:BoundField DataField="other_comments" HeaderText="Other Comments" SortExpression="other_comments"
ReadOnly="True" />
<asp:BoundField DataField="DateTime" HeaderText="Date"
SortExpression="DateTime" />
<asp:BoundField DataField="IP" HeaderText="Client IP" SortExpression="IP" />
<asp:ButtonField ButtonType="Button" Text="Trace IP to Map" />
</Columns>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
<PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
开发者_如何转开发 <SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#4B4B4B" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#242121" />
</asp:GridView>
Thank you in advance for the help!
Try using a HyperLinkField
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.aspx
<asp:HyperLinkField
HeaderText="Client IP"
DataNavigateUrlFields="IP"
DataNavigateUrlFormatString="some-page.aspx?id={0}"
DataTextField="IP"
DataTextFormatString="{0}"
Target="_blank"/>
精彩评论