dcsimg
Results 1 to 7 of 7

Thread: Best way to handle this

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2019
    Posts
    17

    Best way to handle this

    Good morning,

    I am looking to lean on some knowledge of very experienced coders in this forum, as I am still relatively new. I'm building a server portal to manage servers hosted elsewhere, the serverID that I use in the API is stored locally and retrieved from the user line in the DB.

    The below works fine, if, the customer only has one server. If they were to have multiple, what would be the best way to handle it?

    Current Subs (shows how the serverID is found, and how the API query is made);

    Code:
      Protected Sub GetUserServers()
            Dim userid As String = HttpContext.Current.Session("UserId")
            Dim connection As New SqlConnection("Data Source=ID17603\SQLEXPRESS;Initial Catalog=dedicatix;Integrated Security=True")
            Dim dt As New DataTable
            connection.Open()
            Dim sqlcmd As New SqlCommand("Select * from servers where userID = @UserID", connection)
            Dim sqlda As New SqlDataAdapter(sqlcmd)
            sqlcmd.Parameters.AddWithValue("@UserID", userid)
            Dim reader As SqlDataReader = sqlcmd.ExecuteReader()
            While reader.Read()
                ServerID.Text = reader("apiReference")
            End While
    
        End Sub
    
        Private Sub ServerSpecificData()
            'STANDARD SETUP FOR APICLEINT And AUTH INFO
            Dim apiClient = New MyServersApi.MyServersApiClient()
            Dim authInfo As New MyServersApi.AuthInfo()
            authInfo.Username = "#######"
            authInfo.Password = "#########"
    
            Dim SpecificServer = apiClient.GetServerDetails(authInfo, ServerID.Text)
    
            YourRef.Text = SpecificServer.YourReference
            Type.Text = SpecificServer.DeviceType
            PrimaryIP.Text = SpecificServer.PrimaryIP
            Location.Text = SpecificServer.Location
            Status.Text = SpecificServer.Status
        End Sub
    Current .aspx code related;

    Code:
    <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0" runat="server">
                      <thead>
                        <tr>
                          <th>Server ID</th>
                          <th>Your Ref</th>
                          <th>Type</th>
                          <th>IPv4 Address</th>
                          <th>Location</th>
                          <th>Current Status</th>
                        </tr>
                      </thead>
                     
                      <tbody>
                        <tr>
                          <td><asp:Label ID="ServerID" runat="server" Text=""></asp:Label></td>
                          <td><asp:Label ID="YourRef" runat="server" Text=""></asp:Label></td>
                          <td><asp:Label ID="Type" runat="server" Text=""></asp:Label></td>
                          <td><asp:Label ID="PrimaryIP" runat="server" Text=""></asp:Label></td>
                          <td><asp:Label ID="Location" runat="server" Text=""></asp:Label></td>
                          <td><asp:Label ID="Status" runat="server" Text=""></asp:Label></td>
                        </tr>
                      </tbody>
                    </table>

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,158

    Re: Best way to handle this

    At a glance, the obvious option is a list or grid of some sort that displays each server and the user makes a selection from that.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2019
    Posts
    17

    Re: Best way to handle this

    Quote Originally Posted by jmcilhinney View Post
    At a glance, the obvious option is a list or grid of some sort that displays each server and the user makes a selection from that.
    Thank you, it may help if I show visually what I am trying to achieve. The below is the dashboard as is, and, I want subsequent servers (if applicable) to be listed below that one.

    Name:  dashboard.jpg
Views: 85
Size:  16.3 KB

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,722

    Re: Best way to handle this

    That looks like either a DataGridView or a ListView in Detail mode. Of the two,the DGV is simpler to use, and probably best suited to this task. There are MANY properties to the DGV, and you'd have to fiddle with them to get the appearance you want. For example, by default you'll get row headers, and the grid will look different from column and row headers. You'd have to fiddle with display settings to match the display you are showing. Shouldn't be too hard, though.


    The ListView offers few advantages over the DGV, though you can often get some more interesting graphics effects with the ListView….which you likely don't care about at all, based on the image shown. If you wanted to put some kind of status icon to the left of each server, then the ListView might be a simpler way to do that. Otherwise, the DGV would be best. Build a datatable, fill that with the server information, then bind that to the DGV.
    My usual boring signature: Nothing

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,158

    Re: Best way to handle this

    The DataGridView is a Windows Forms control but it appears that your application is web-based. If it's Web Forms then a GridView would be the equivalent. If it's MVC then there are various third-party grid options, both paid and free, or you can roll your own.

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    5,625

    Re: Best way to handle this

    I was about to write about the DGV.
    I think this is better suited in ASP.NET forum and you must show your markup.
    Slow as hell.

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,722

    Re: Best way to handle this

    Yeah ASP.NET looks right, so I've moved it. If that proves to be incorrect, report this post and let us know.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width