Add hyperlink a asp:datagrid (VB.net) : DataGrid « Asp Control « ASP.Net

ASP.Net
1. ADO.net Database
2. Asp Control
3. Collections
4. Components
5. Data Binding
6. Development
7. HTML Control
8. Mobile Control
9. Page
10. Request
11. Response
12. Server
13. Session Cookie
14. User Control and Master Page
15. Validation by Control
16. Validation by Function
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
ASP.Net » Asp Control » DataGrid 
Add hyperlink a asp:datagrid (VB.net)

<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    If Not IsPostBack Then 
        Dim MyDT As New DataTable
        Dim MyRow As DataRow
        MyDT.Columns.Add(New DataColumn("EmployeeID", _
            GetType(Int32)))
        MyDT.Columns.Add(New DataColumn("EmployeeFirstName", _
            GetType(String)))
        MyDT.Columns.Add(New DataColumn("EmployeeLastName", _
            GetType(String)))
        MyDT.Columns.Add(New DataColumn("BirthDate", _
            GetType(Date)))
        MyDT.Columns.Add(New DataColumn("Salary", _
            GetType(Single)))

        MyRow = MyDT.NewRow()
        MyRow(01
        MyRow(1"Bob"
        MyRow(2"Miller"
        MyRow(3"5/15/65"
        MyRow(4"40000"
        MyDT.Rows.Add(MyRow)
        MyRow = MyDT.NewRow()
        MyRow(02
        MyRow(1"Jenny"
        MyRow(2"Fry"
        MyRow(3"7/22/75"
        MyRow(4"73050"
        MyDT.Rows.Add(MyRow)
        MyRow = MyDT.NewRow()
        MyRow(03
        MyRow(1"Lisa"
        MyRow(2"Smith"
        MyRow(3"12/8/71"
        MyRow(4"62500"
        MyDT.Rows.Add(MyRow)
        MyRow = MyDT.NewRow()
        MyRow(04
        MyRow(1"Stephanie"
        MyRow(2"Myer"
        MyRow(3"3/15/54"
        MyRow(4"43222"
        MyDT.Rows.Add(MyRow)
        MyRow = MyDT.NewRow()
        MyRow(05
        MyRow(1"Jimmy"
        MyRow(2"Parker"
        MyRow(3"3/12/47"
        MyRow(4"52825"
        MyDT.Rows.Add(MyRow)

        dg1.DataSource = MyDT
        dg1.DataBind()
    End If
    If Len(Request.QueryString("EmployeeID")) Then
        lblMessage.Text = "You selected employee " _
            & Request.QueryString("EmployeeID"".<BR>"
    End If
End Sub
Sub Click_Grid(ByVal Sender as Object, ByVal E as DataGridCommandEventArgs)
    lblMessage.Text = "You selected " _
        & E.Item.Cells(2).Text & " " _
        & E.Item.Cells(1).Text & "<BR>"
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>DataGrid Control Sample Page</TITLE>
</HEAD>
<BODY >
<form runat="server">
<Font Face="Tahoma">
<asp:Label
    id="lblMessage"
    runat="server"
/>
<BR>
<ASP:DataGrid 
    id="dg1" 
    runat="server"
    Width="90%"
    BorderColor="black"
    CellPadding=
    CellSpacing="0"
    Font-Name="Trebuchet MS"
    Font-Size="10pt"
    ForeColor="Black"
    BackColor="Beige" 
    AlternatingItemStyle-ForeColor="Cornsilk"
    AlternatingItemStyle-BackColor="DarkBlue"
    AlternatingItemStyle-Font-Name="Arial"
    AlternatingItemStyle-Font-Italic="True"
    HeaderStyle-BackColor="Burlywood"
    HeaderStyle-Font-Bold="True"
    AutoGenerateColumns="false"
    OnItemCommand="Click_Grid"
>
    <Columns>
        <asp:HyperLinkColumn
            HeaderText="Employee ID"
            DataNavigateUrlField="EmployeeID"
            
            DataNavigateUrlFormatString="./thispage.aspx?EmployeeID={0}"
            DataTextField="EmployeeID"
            Target="_self"
        />
        <asp:BoundColumn 
            HeaderText="Last Name" 
            DataField="EmployeeLastName"
        />
        <asp:BoundColumn 
            HeaderText="First Name" 
            DataField="EmployeeFirstName"
        />
        <asp:BoundColumn 
            HeaderText="Salary"
            DataField="Salary"
            DataFormatString="{0:C}"
        />
        <asp:BoundColumn 
            HeaderText="Birth Date"
            DataField="BirthDate"
            DataFormatString="{0:d}"
        />
        <asp:ButtonColumn 
            HeaderText="Click for Fun" 
            ButtonType="PushButton" 
            Text="Click Me"
        />
    </Columns>  
</asp:DataGrid>
</Font>
</Form>
</BODY>
</HTML>
           
       
Related examples in the same category
1. Add data to datagrid (VB.net)
2. BorderColor, CellPadding, CellSpacing for ASP:DataGrid (VB.net)
3. Font-Name, Font-Size for ASP:DataGrid (VB.net)
4. ForeColor, BackColor for ASP:DataGrid (VB.net)
5. AlternatingItemStyle-ForeColor, AlternatingItemStyle-BackColor for ASP:DataGrid (VB.net)
6. AlternatingItemStyle-Font-Name, AlternatingItemStyle-Font-Italic (VB.net)
7. HeaderStyle-BackColor, HeaderStyle-Font-Bold (VB.net)
8. Add button to asp:DataGrid (VB.net)
9. Add hyperlink to asp:datagrid table column (VB.net)
10. Add navigator to asp:datagrid (VB.net)
11. Set item style, header style and alternating item style for the asp datagrid (C#)
w_w_w._j__a___v___a2s.com___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.