Solved

Help adding link to item in grid view asp.net

Posted on 2011-09-20
3
367 Views
Last Modified: 2012-05-12
My page looks like this: http://www.shatterboxwebdesign.com/slsdelete/admin_eenvelope_delete.aspx.htm 

and the original is in asp.net. I want to change the "document" column so tat when the user clicks it will open the document in a new window. The code for the page is below, can someone who knows asp.net show me how to do this?

Thanks


<%@ Page Language="VB" MasterPageFile="~/admin_MasterPage.master" validateRequest="False" AutoEventWireup="false" CodeFile="admin_eenvelope_delete.aspx.vb" Inherits="admin_eenvelope_delete" title="" Debug="true" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    <script type="text/javascript">
if (document.images) {
    img1 = new Image();
    img1.src = "images/delete_button_on.png";
}
</script>
<script type="text/javascript" language="javascript">
function DeleteConfirmation()
{
if (confirm("Are you sure, you want to delete selected records ?")==true)
   return true;
else
   return false;
}
</script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="Message" runat="server" Text=""></asp:Label>

    <span class="style1">Delete eEnvelope Items</span><br /><br />
    <div align="center">
<asp:GridView ID="GridView1" runat="server"
              AutoGenerateColumns="False"
              DataSourceID="SqlDataSource1"
              ShowFooter="true">
     <Columns>
     <asp:TemplateField HeaderText="Delete?" ShowHeader="true" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="80px" ItemStyle-HorizontalAlign="Center">
     <ItemTemplate>
     <asp:CheckBox ID="chkSelect" runat="server" />
     </ItemTemplate>
     <FooterTemplate>
        <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/images/delete_button_off.png" OnClick="btnDelete_Click" OnClientClick="return DeleteConfirmation();"/>
     <script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $('#ctl00_ContentPlaceHolder1_GridView1_ctl03_btnDelete').hover(
            function(){ // Change the input image's source when we "roll on"
                $(this).attr({ src : 'images/delete_button_on.png'});
            },
            function(){ // Change the input image's source back to the default on "roll off"
                $(this).attr({ src : 'images/delete_button_off.png'});             }
        );
    });
</script>
      </FooterTemplate>
      </asp:TemplateField>
      <asp:BoundField DataField="id"
                      HeaderText="ID"
                      SortExpression="id"
                      HeaderStyle-Width="200px"
                      ItemStyle-HorizontalAlign="Center" />
      <asp:BoundField DataField="doc_loc"
                      HeaderText="Document"
                      SortExpression="doc_loc"
                      HeaderStyle-Width="200px"
                      ItemStyle-HorizontalAlign="Center" />
      </Columns>
     
     <HeaderStyle BackColor="#99CCFF" />
     
     <AlternatingRowStyle BackColor="#99CCFF" Wrap="False" />
</asp:GridView>
</div>
    <br />
   
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
  ConnectionString="<%$ ConnectionStrings:stluke %>"
     SelectCommand="SELECT [id], [doc_loc] FROM [elliott_tod10].[eenvelope]"></asp:SqlDataSource>
<br />
<br />
    <%-- %><asp:ImageButton id="btnDelete" runat="server" ImageUrl="~/images/delete_event_off.png" OnClick="btnDelete_Click" />
    <script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $('#ctl00_ContentPlaceHolder1_ImageButton1').hover(
            function(){ // Change the input image's source when we "roll on"
                $(this).attr({ src : 'images/delete_event_on.png'});
            },
            function(){ // Change the input image's source back to the default on "roll off"
                $(this).attr({ src : 'images/delete_event_off.png'});             }
        );
    });
</script> --%>
    <br />

<%-- <input type="image" name="add_event" id="add_event" src="images/add_event_off.png" runat="server"> --%>
            
</asp:Content>



0
Comment
Question by:elliottbenzle
3 Comments
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points
ID: 36571508
Hi,
Replace below code
 <asp:BoundField DataField="doc_loc"
                      HeaderText="Document"
                      SortExpression="doc_loc"
                      HeaderStyle-Width="200px"
                      ItemStyle-HorizontalAlign="Center" />
with

<asp:TemplateField HeaderText="Document" >
     <ItemTemplate>
       <asp:hyperlinkfield text="<%# Eval("LastName") %>"  navigateurl="yourpath<%# Eval("LastName") %>" target="_blank" />
    </ItemTemplate>
</asp:TemplateField>

Regards,
Ram
0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 36571794
<asp:TemplateField HeaderText="Document">
<ItemTemplate>
<asp:HyperLink ID="hlLink" runat="server" ="<%# Eval("doc_loc") %>"   navigateurl="path to be browsed" target="_blank"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>

or

<asp:TemplateField HeaderText="Document">
<ItemTemplate>
<asp:HyperLink ID="hlLink" runat="server" ="<%# Eval("doc_loc") %>"   onclientclick="javascript:window.open('your page');"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>


0
 
LVL 4

Author Closing Comment

by:elliottbenzle
ID: 36573923
Still needs a little tweeking, but this helped. Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Trying to use colormap to replace color in png, with a gradient to transparent 7 31
SSRS ReportViewer report timeout 7 106
Not showing page correctly 3 31
Run time Error 4 35
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now