Click here to Skip to main content
16,016,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am displaying invoice no in first column of the grid. It will be like InvoiceNo:123456. Its like a link. If it is not invoiceno link will not come to that column. How to do this.plz help me. I used this script.

XML
<script id="script1" type="text/javascript">
         function GetFileFromDB(Cash_Description) {
             window.location = "View_Invoice.aspx?CInvoiceNo=" + Cash_Description;
         }
   </script>


I used in grid like this
XML
<ItemTemplate>
                         <a href="javascript:GetFileFromDB('<%# Eval("Cash_Description") %>')">
                         <asp:Literal ID="Literal2" runat="server" Text='<%# Eval("Cash_Description") %>' Mode="Transform">

                        </asp:Literal></a>
Posted

You are putting the data into the grid. It is either going to be an invoiceNo or it isn't, only you know, because it is you who specifies the data to be retrieved.

If you decide that it is an invoiceNo then do an internet search on something like asp.net gridview hyperlink column. You will get hundreds of different ways to do it, select the one that you like the best.
 
Share this answer
 
Comments
Jayanthi-SE 19-Apr-11 9:56am    
ok i will search
you can check the column data... if you found Invoice no then show that link otherwise hide that link using style="display:None;"...
this can you do with calling any javascript function or do it at databound event of grid
 
Share this answer
 
Comments
Jayanthi-SE 19-Apr-11 9:59am    
i have one column name as cash_description, Data will insert like Invoice No:123456 and Others:Self if that column is Invoice No:123456 then link will come if it is Others:Self link will not come to this. I dont have idea how to do this. if u have any idea plz help me. I dont know how to do condition there.
VB
Public Function dealphotocut1(ByVal a As String) As String


        If a.Length >= 18 Then
            Dim str As String = a
            Dim str1, str2 As String
            Dim str3 As String = ""
            str1 = str.Substring(0, 11)
            str2 = str.Substring(11, 7)
            If str1 = "Invoice No:" Then
                str3 = "<a href='View_Invoice.aspx?CInvoiceNo=" & str2 & "' Target='_blank'>Invoice No:" & str2 & "</a>"
                Return str3

            End If
        Else
            Return a
        End If

    End Function


XML
<asp:TemplateField HeaderText="Cash Description">
                        <ItemTemplate>

                            <asp:Label ID="Label37" runat="server" Text='<%# dealphotocut1(Eval("Cash_Description"))%>'></asp:Label>
                        </ItemTemplate>

                                            <ItemStyle HorizontalAlign="Center" />
                                                </asp:TemplateField>
 
Share this answer
 
You can try this

//You can enabled or disabled your hyperlink like  below

protected void grd_SearchCandidates_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           //find HtmlAnchor tag in gridview
           HyperLink hyp = (HyperLink)e.Row.FindControl("hyp_Isfresher");
           if (hyp.Text == "Fresher")
           {
               hyp.Enabled = false;
           }
           else
           {
               hyp.Enabled = true;
           }
       }
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900