Datagrid item selection

Discussion in 'ASP .Net' started by slinky, Jun 3, 2008.

  1. slinky

    slinky Guest

    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="False" BorderColor="Silver"
    AllowSorting="True" HorizontalAlign="Center"
    BorderStyle="Solid" Height="133px" Width="584px">
    <SelectedItemStyle Font-Underline="True"></SelectedItemStyle>
    <AlternatingItemStyle BackColor="#C0FFC0"></AlternatingItemStyle>
    </asp:datagrid>


    CODE BEHIND:

    Public Class MainDepartment
    Inherits System.Web.UI.Page

    Private m_department As String
    Private m_title As String
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    lblWelcome.Text = "Hello " & Global.UserSecurity.Fname.Trim &
    " " & Global.UserSecurity.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).GetActionCurrent(Global.UserSecurity.EmpId, Today,
    Global.UserName, Global.UserPassword, Global.appDataSource)
    pos = (New PositionBroker).GetPosition(act.PositionID,
    Global.UserName, Global.UserPassword, Global.appDataSource)
    m_department = pos.Department.Name
    Dim emps As Employees = (New
    EmployeeBroker).GetCurrentEmployeesByDepartment(m_department,
    Global.UserName, Global.UserPassword, Global.appDataSource)
    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.DataSource = dt
    dgEmployees.DataBind()

    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).GetActionCurrent(dr.Key, Today, Global.UserName,
    Global.UserPassword, Global.appDataSource)
    Dim employee As DataRow = dt.NewRow
    employee("Last Name") = dr.LastName
    employee("First Name") = dr.FirstName
    employee("Title") = EmpPos.WorkAgainstInfo.Title
    dt.Rows.Add(employee)
    End Sub 'SetListViewItem
    slinky, Jun 3, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Niederberger
    Replies:
    2
    Views:
    16,419
    Christian Kaufhold
    Jan 7, 2005
  2. Andrew Crowe
    Replies:
    1
    Views:
    4,438
    Andrew Crowe
    Sep 13, 2004
  3. Replies:
    0
    Views:
    349
  4. slinky

    Datagrid item selection

    slinky, Jun 3, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    278
    slinky
    Jun 3, 2008
  5. QUASAR
    Replies:
    6
    Views:
    405
    QUASAR
    Jan 17, 2004
Loading...

Share This Page