I'm using VS2003 VB.net/ASP.net and have a Datagrid on an .ASPX page
that is successfully displaying the records I was expecting. The next
step I want to do is to double-click a line (record) and launch
another page that has the more details of that record displayed (and
of course only that record).
Can anyone give some lues or hyperlinks to accomplishing this? I've
heard of using DataView, but I don't think this is available in the
2003 version (?).
In case needed, here is my code:
<asp:datagrid id="dgEmployees " style="Z-INDEX: 103; LEFT: 12px;
POSITION: absolute; TOP: 12px"
runat="server" ShowHeader="Fal se" BorderColor="Si lver"
AllowSorting="T rue" HorizontalAlign ="Center"
BorderStyle="So lid" Height="133px" Width="584px">
<SelectedItemSt yle Font-Underline="True "></SelectedItemSty le>
<AlternatingIte mStyle BackColor="#C0F FC0"></AlternatingItem Style>
</asp:datagrid>
CODE BEHIND:
Public Class MainDepartment
Inherits System.Web.UI.P age
Private m_department As String
Private m_title As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
lblWelcome.Text = "Hello " & Global.UserSecu rity.Fname.Trim &
" " & Global.UserSecu rity.Lname
Dim act As Action
Dim pos As Position
Dim empname As String
Dim lvi As ListItem
Dim Employee As Employee
Dim empcount As Integer
act = (New
ActionBroker).G etActionCurrent (Global.UserSec urity.EmpId, Today,
Global.UserName , Global.UserPass word, Global.appDataS ource)
pos = (New PositionBroker) .GetPosition(ac t.PositionID,
Global.UserName , Global.UserPass word, Global.appDataS ource)
m_department = pos.Department. Name
Dim emps As Employees = (New
EmployeeBroker) .GetCurrentEmpl oyeesByDepartme nt(m_department ,
Global.UserName , Global.UserPass word, Global.appDataS ource)
Dim dt As New DataTable
Dim count As Integer = 0
For Each emp As Employee In emps
SetListViewItem (emp, dt, count)
count = count + 1
Next
dgEmployees.Dat aSource = dt
dgEmployees.Dat aBind()
End Sub
Private Sub SetListViewItem (ByVal dr As Employee, ByVal dt As
DataTable, ByVal count As Integer)
If count = 0 Then
dt.Columns.Add( "Last Name")
dt.Columns.Add( "First Name")
dt.Columns.Add( "Title")
End If
Dim EmpPos As Action = (New
ActionBroker).G etActionCurrent (dr.Key, Today, Global.UserName ,
Global.UserPass word, Global.appDataS ource)
Dim employee As DataRow = dt.NewRow
employee("Last Name") = dr.LastName
employee("First Name") = dr.FirstName
employee("Title ") = EmpPos.WorkAgai nstInfo.Title
dt.Rows.Add(emp loyee)
End Sub 'SetListViewIte m
that is successfully displaying the records I was expecting. The next
step I want to do is to double-click a line (record) and launch
another page that has the more details of that record displayed (and
of course only that record).
Can anyone give some lues or hyperlinks to accomplishing this? I've
heard of using DataView, but I don't think this is available in the
2003 version (?).
In case needed, here is my code:
<asp:datagrid id="dgEmployees " style="Z-INDEX: 103; LEFT: 12px;
POSITION: absolute; TOP: 12px"
runat="server" ShowHeader="Fal se" BorderColor="Si lver"
AllowSorting="T rue" HorizontalAlign ="Center"
BorderStyle="So lid" Height="133px" Width="584px">
<SelectedItemSt yle Font-Underline="True "></SelectedItemSty le>
<AlternatingIte mStyle BackColor="#C0F FC0"></AlternatingItem Style>
</asp:datagrid>
CODE BEHIND:
Public Class MainDepartment
Inherits System.Web.UI.P age
Private m_department As String
Private m_title As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
lblWelcome.Text = "Hello " & Global.UserSecu rity.Fname.Trim &
" " & Global.UserSecu rity.Lname
Dim act As Action
Dim pos As Position
Dim empname As String
Dim lvi As ListItem
Dim Employee As Employee
Dim empcount As Integer
act = (New
ActionBroker).G etActionCurrent (Global.UserSec urity.EmpId, Today,
Global.UserName , Global.UserPass word, Global.appDataS ource)
pos = (New PositionBroker) .GetPosition(ac t.PositionID,
Global.UserName , Global.UserPass word, Global.appDataS ource)
m_department = pos.Department. Name
Dim emps As Employees = (New
EmployeeBroker) .GetCurrentEmpl oyeesByDepartme nt(m_department ,
Global.UserName , Global.UserPass word, Global.appDataS ource)
Dim dt As New DataTable
Dim count As Integer = 0
For Each emp As Employee In emps
SetListViewItem (emp, dt, count)
count = count + 1
Next
dgEmployees.Dat aSource = dt
dgEmployees.Dat aBind()
End Sub
Private Sub SetListViewItem (ByVal dr As Employee, ByVal dt As
DataTable, ByVal count As Integer)
If count = 0 Then
dt.Columns.Add( "Last Name")
dt.Columns.Add( "First Name")
dt.Columns.Add( "Title")
End If
Dim EmpPos As Action = (New
ActionBroker).G etActionCurrent (dr.Key, Today, Global.UserName ,
Global.UserPass word, Global.appDataS ource)
Dim employee As DataRow = dt.NewRow
employee("Last Name") = dr.LastName
employee("First Name") = dr.FirstName
employee("Title ") = EmpPos.WorkAgai nstInfo.Title
dt.Rows.Add(emp loyee)
End Sub 'SetListViewIte m