Datagrid/Datalist, same page, 2nd is details

Discussion in 'ASP .Net' started by Brock, Jul 3, 2008.

  1. Brock

    Brock Guest

    First note that I am using Framework 1.1. I have an .aspx page that is
    displaying a list of employees, but only the Employee Number, First
    Name, Last Name, and Title. It is working great. I recessed it in a
    <Div></Div> to allow scrolling of just the data, not the page. What I
    need to do is place a DataList (also in a <Div></Div> to allow
    scrolling of just the data) to the right of the Datagrid to show 40
    Employee Detail fields (listed top to bottom). Ideally I'd like to
    have a "Select" in the first column to allow the user to click on that
    employee and see the scrollable details listed for that employee in
    the DataList to the right of the DataGrid. Below is my html and below
    that is my code-behind. What I need help with is getting a "Select"
    column in and causing upon pressing that the rest of the 40 fileds to
    display... Thanks for any clues! (also how can I get
    both the DG and the DL to be placed side-by-side? I can't seem to move
    these around in the designer.)



    <%@ Page Language="vb" AutoEventWireup="false"
    Codebehind="MainDepartment.aspx.vb"
    Inherits="Forsyth.HR_ReportingTool.UI.MainDepartment" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>MainDepartment</title>
    <META http-equiv="Content-Type" content="text/html;
    charset=windows-1252">
    <meta content="False" name="vs_snapToGrid">
    <meta content="False" name="vs_showGrid">
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5"
    name="vs_targetSchema">
    </HEAD>
    <BODY background="file:///C:\Inetpub\wwwroot\HR_ReportingTool
    \vignette.gif">
    <div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FONT-SIZE:
    medium; BORDER-LEFT-COLOR: white; FLOAT: none; BORDER-BOTTOM-COLOR:
    white; MARGIN-LEFT: 20px; OVERFLOW: auto; WIDTH: 701px; CLIP:
    rect(auto auto auto auto); COLOR: black; BORDER-TOP-STYLE: inset;
    BORDER-TOP-COLOR: white; TEXT-INDENT: 5%; FONT-FAMILY: 'Times New
    Roman'; BORDER-RIGHT-STYLE: inset; BORDER-LEFT-STYLE: inset; HEIGHT:
    599px; BACKGROUND-COLOR: white; TEXT-ALIGN: left; BORDER-RIGHT-COLOR:
    white; BORDER-BOTTOM-STYLE: inset"
    align="left">
    <DIV>
    <FORM id="Form1" method="post" runat="server">
    <asp:datagrid id="dgEmployees" Width="640px" BorderStyle="Solid"
    runat="server" Height="136px"
    HorizontalAlign="Center" AllowSorting="True"
    BorderColor="Silver" Font-Size="X-Small">
    <SelectedItemStyle Font-Underline="True" Font-Bold="True"></
    SelectedItemStyle>
    <AlternatingItemStyle BackColor="#C0FFC0"></
    AlternatingItemStyle>
    </asp:datagrid></FORM>
    </DIV>
    </div>
    </BODY>
    </HTML>




    _______________________________________________________________________________________________________
    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("Emp #")
    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("Emp #") = dr.Key
    employee("Last Name") = dr.LastName
    employee("First Name") = dr.FirstName
    employee("Title") = EmpPos.WorkAgainstInfo.Title
    dt.Rows.Add(employee)
    End Sub 'SetListViewItem

    Private Function FindEmp(ByVal EmployeeID As Integer) As String
    Dim emp As Employee
    Dim retval As String
    Try
    If EmployeeID > 0 Then
    emp = (New EmployeeBroker).GetEmployee(EmployeeID,
    Global.UserName, Global.UserPassword, Global.appDataSource)
    retval = String.Empty
    If Not IsNothing(emp) Then
    retval = emp.FirstName & " " & emp.MI & " " &
    emp.LastName
    Else
    retval = "Vacant"
    End If
    Else
    retval = ""
    End If
    Catch ex As Exception
    Global.HandleException(ex)
    retval = String.Empty
    End Try
    Return retval
    End Function

    End Class
     
    Brock, Jul 3, 2008
    #1
    1. Advertising

  2. Brock

    Brock Guest

    I was able to get my DataList placed on my form to the right of the
    DataGrid. Now all I need to figure out is how to put in a "Select"
    column and when the user presses that for a specific employee record
    the DataList will be populated with the rest of the fields. Any
    clues? Thanks!!! Below is my revised code. The
    code-behind has not been changed from my original post.



    <%@ Page Language="vb" AutoEventWireup="false"
    Codebehind="MainDepartment.aspx.vb"
    Inherits="Forsyth.HR_ReportingTool.UI.MainDepartment" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>MainDepartment</title>
    <META http-equiv="Content-Type" content="text/html;
    charset=windows-1252">
    <meta content="False" name="vs_snapToGrid">
    <meta content="False" name="vs_showGrid">
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5"
    name="vs_targetSchema">
    </HEAD>
    <BODY background="file:///C:\Inetpub\wwwroot\HR_ReportingTool
    \vignette.gif">
    <div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FONT-SIZE:
    medium; BORDER-LEFT-COLOR: white; LEFT: 50px; FLOAT: none; BORDER-
    BOTTOM-COLOR: white; MARGIN-LEFT: 20px; OVERFLOW: auto; WIDTH: 736px;
    CLIP: rect(auto auto auto auto); COLOR: black; BORDER-TOP-STYLE:
    inset; BORDER-TOP-COLOR: white; TEXT-INDENT: 5%; FONT-FAMILY: 'Times
    New Roman'; BORDER-RIGHT-STYLE: inset; BORDER-LEFT-STYLE: inset;
    POSITION: absolute; TOP: 50px; HEIGHT: 599px; BACKGROUND-COLOR: white;
    TEXT-ALIGN: left; BORDER-RIGHT-COLOR: white; BORDER-BOTTOM-STYLE:
    inset"
    align="left">
    <DIV style="POSITION: absolute">
    <FORM id="Form1" method="post" runat="server">
    <asp:datagrid id="dgEmployees" runat="server" Font-Size="X-Small"
    BorderColor="Silver" AllowSorting="True"
    HorizontalAlign="Center" BorderStyle="Solid" Height="136px"
    Width="640px">
    <SelectedItemStyle Font-Underline="True" Font-Bold="True"></
    SelectedItemStyle>
    <AlternatingItemStyle BackColor="#C0FFC0"></
    AlternatingItemStyle>
    </asp:datagrid></FORM>
    </DIV>
    </div>
    <div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FONT-SIZE:
    medium; BORDER-LEFT-COLOR: white; LEFT: 800px; FLOAT: none; BORDER-
    BOTTOM-COLOR: white; MARGIN-LEFT: 20px; OVERFLOW: auto; WIDTH: 326px;
    CLIP: rect(auto auto auto auto); COLOR: black; BORDER-TOP-STYLE:
    inset; BORDER-TOP-COLOR: white; TEXT-INDENT: 5%; FONT-FAMILY: 'Times
    New Roman'; BORDER-RIGHT-STYLE: inset; BORDER-LEFT-STYLE: inset;
    POSITION: absolute; TOP: 50px; HEIGHT: 598px; BACKGROUND-COLOR:
    #ffcc66; TEXT-ALIGN: left; BORDER-RIGHT-COLOR: white; BORDER-BOTTOM-
    STYLE: inset"
    align="left"><asp:datalist id="dlDetails" Font-Size="X-Small"
    BorderColor="Silver" Height="350px" runat="server"
    Width="309px" RepeatLayout="Flow">
    <ItemTemplate>
    <B>Emp #: </B>
    <%# Container.DataItem("Key") %>
    <br>
    <B>First Name: </B>
    <%# Container.DataItem("FirstName") %>
    <br>
    <B>Last name: </B>
    <%# Container.DataItem("LastName") %>
    <br>
    <B>Added By: </B>
    <%# Container.DataItem("AddedBy") %>
    <br>
    <B>Added By Name: </B>
    <%# Container.DataItem("AddedByName") %>
    <br>
    <B>Added Date: </B>
    <%# Container.DataItem("AddedDateString") %>
    <br>
    <B>Ad Username: </B>
    <%# Container.DataItem("AdUsername") %>
    <br>
    <B>Advance Leave: </B>
    <%# Container.DataItem("AdvanceLeave") %>
    <br>
    <B>Benefits: </B>
    <%# Container.DataItem("Benefits") %>
    <br>
    <B>Cobra: </B>
    <%# Container.DataItem("Cobra") %>
    <br>
    <B>DOB: </B>
    <%# Container.DataItem("DOBString") %>
    <br>
    <B>Email Address: </B>
    <%# Container.DataItem("EmailAddress") %>
    <br>
    <B>Evaluation Due: </B>
    <%# Container.DataItem("EvaluationDueString") %>
    <br>
    <B>Gender: </B>
    <%# Container.DataItem("Gender") %>
    <br>
    <B>Home Phone: </B>
    <%# Container.DataItem("HomePhoneFormatted") %>
    <br>
    <B>Law Sep: </B>
    <%# Container.DataItem("LawSep") %>
    <br>
    <B>LOA: </B>
    <%# Container.DataItem("LOA") %>
    <br>
    <B>Login Name: </B>
    <%# Container.DataItem("LoginName") %>
    <br>
    <B>Longevity Date: </B>
    <%# Container.DataItem("LongevityDate") %>
    <br>
    <B>MI: </B>
    <%# Container.DataItem("MI") %>
    <br>
    <B>Nick Name: </B>
    <%# Container.DataItem("NickName") %>
    <br>
    <B>Payroll Employee ID: </B>
    <%# Container.DataItem("PayrollEmployeeID") %>
    <br>
    <B>Race: </B>
    <%# Container.DataItem("Race") %>
    <br>
    <B>Retiree: </B>
    <%# Container.DataItem("Retiree") %>
    <br>
    <B>Retirement Number: </B>
    <%# Container.DataItem("RetirementNumber") %>
    <br>
    <B>Service Date String: </B>
    <%# Container.DataItem("ServiceDateString") %>
    <br>
    <B>Suffix: </B>
    <%# Container.DataItem("Sfx") %>
    <br>
    <B>Start Date String: </B>
    <%# Container.DataItem("StartDateString") %>
    <br>
    <B>Status: </B>
    <%# Container.DataItem("Status") %>
    <br>
    <B>Updated By: </B>
    <%# Container.DataItem("UpdatedBy") %>
    <br>
    <B>Updated By Name: </B>
    <%# Container.DataItem("UpdatedByName") %>
    <br>
    <B>Updated Date String: </B>
    <%# Container.DataItem("UpdatedDateString") %>
    <br>
    <B>Use Nick Name Only: </B>
    <%# Container.DataItem("UseNickNameOnly") %>
    <br>
    </ItemTemplate>
    </asp:datalist></div>
    </BODY>
    </HTML>






    On Jul 3, 11:45 am, Brock <> wrote:
    > First note that I am using Framework 1.1. I have an .aspx page that is
    > displaying a list of employees, but only the Employee Number, First
    > Name, Last Name, and Title. It is working great. I recessed it in a
    > <Div></Div> to allow scrolling of just the data, not the page. What I
    > need to do is place a DataList (also in a <Div></Div> to allow
    > scrolling of just the data) to the right of the Datagrid to show 40
    > Employee Detail fields (listed top to bottom). Ideally I'd like to
    > have a "Select" in the first column to allow the user to click on that
    > employee and see the scrollable details listed for that employee in
    > the DataList to the right of the DataGrid. Below is my html and below
    > that is my code-behind. What I need help with is getting a "Select"
    > column in and causing upon pressing that the rest of the 40 fileds to
    > display... Thanks for any clues!                (also how can I get
    > both the DG and the DL to be placed side-by-side? I can't seem to move
    > these around in the designer.)
    >
    > <%@ Page Language="vb" AutoEventWireup="false"
    > Codebehind="MainDepartment.aspx.vb"
    > Inherits="Forsyth.HR_ReportingTool.UI.MainDepartment" %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML>
    >  <HEAD>
    >   <title>MainDepartment</title>
    >   <META http-equiv="Content-Type" content="text/html;
    > charset=windows-1252">
    >   <meta content="False" name="vs_snapToGrid">
    >   <meta content="False" name="vs_showGrid">
    >   <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    >   <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
    >   <meta content="JavaScript" name="vs_defaultClientScript">
    >   <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > name="vs_targetSchema">
    >  </HEAD>
    >  <BODY background="file:///C:\Inetpub\wwwroot\HR_ReportingTool
    > \vignette.gif">
    >   <div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; FONT-SIZE:
    > medium; BORDER-LEFT-COLOR: white; FLOAT: none; BORDER-BOTTOM-COLOR:
    > white; MARGIN-LEFT: 20px; OVERFLOW: auto; WIDTH: 701px; CLIP:
    > rect(auto auto auto auto); COLOR: black; BORDER-TOP-STYLE: inset;
    > BORDER-TOP-COLOR: white; TEXT-INDENT: 5%; FONT-FAMILY: 'Times New
    > Roman'; BORDER-RIGHT-STYLE: inset; BORDER-LEFT-STYLE: inset; HEIGHT:
    > 599px; BACKGROUND-COLOR: white; TEXT-ALIGN: left; BORDER-RIGHT-COLOR:
    > white; BORDER-BOTTOM-STYLE: inset"
    >    align="left">
    >    <DIV>
    >     <FORM id="Form1" method="post" runat="server">
    >      <asp:datagrid id="dgEmployees" Width="640px" BorderStyle="Solid"
    > runat="server" Height="136px"
    >       HorizontalAlign="Center" AllowSorting="True"
    > BorderColor="Silver" Font-Size="X-Small">
    >       <SelectedItemStyle Font-Underline="True" Font-Bold="True"></
    > SelectedItemStyle>
    >       <AlternatingItemStyle BackColor="#C0FFC0"></
    > AlternatingItemStyle>
    >      </asp:datagrid></FORM>
    >    </DIV>
    >   </div>
    >  </BODY>
    > </HTML>
    >
    > ___________________________________________________________________________­____________________________
    > 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("Emp #")
    >             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("Emp #") = dr.Key
    >         employee("Last Name") = dr.LastName
    >         employee("First Name") = dr.FirstName
    >         employee("Title") = EmpPos.WorkAgainstInfo.Title
    >         dt.Rows.Add(employee)
    >     End Sub 'SetListViewItem
    >
    >     Private Function FindEmp(ByVal EmployeeID As Integer) As String
    >         Dim emp As Employee
    >         Dim retval As String
    >         Try
    >             If EmployeeID > 0 Then
    >                 emp = (New EmployeeBroker).GetEmployee(EmployeeID,
    > Global.UserName, Global.UserPassword, Global.appDataSource)
    >                 retval = String.Empty
    >                 If Not IsNothing(emp) Then
    >                     retval = emp.FirstName & " " & emp.MI & " " &
    > emp.LastName
    >                 Else
    >                     retval = "Vacant"
    >                 End If
    >             Else
    >                 retval = ""
    >             End If
    >         Catch ex As Exception
    >             Global.HandleException(ex)
    >             retval = String.Empty
    >         End Try
    >         Return retval
    >     End Function
    >
    > End Class
     
    Brock, Jul 3, 2008
    #2
    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. David D. McCrory

    Set DataList SelectedIndex - 2nd Post

    David D. McCrory, Jan 20, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    643
    David D. McCrory
    Jan 20, 2004
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,884
  3. =?Utf-8?B?Sm9l?=

    Show Details/Hide Details link button

    =?Utf-8?B?Sm9l?=, Mar 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    911
    dkode
    Mar 13, 2006
  4. Sam
    Replies:
    1
    Views:
    785
  5. dh
    Replies:
    2
    Views:
    373
    Jinsong Liu
    Jul 2, 2004
Loading...

Share This Page