Hi,

Im creating a website that will be used to monitor servers, the user can add and remove servers and the servers list will be constantly chaning.

I need to create a generic page to display the monitoring results that will adapt depending on which server the user selects. The graphs and results dispalyed will always be the same however the data will change depending on which server is selected. How would i go about doing this and is there any good examples online?

Would i need to create new pages as servers are loaded? or could i use a master page that changes depending on server?

FOR REFRESH YOU CAN USE AJAX. TO LEARN MORE ON THIS GO TO asp.net learn section. Server means what? Just input & then save??? Need to know details. For graph you can use fusion chart which is free.

hi,

I mean like a windows server or unix server basically monitoring computers and I would like to have one template that could be used for every server, the data about each server is stored in a sql database so when the user selects say server1 it will load the template with all the information about server1, but if they chose server2 then it will load all the information about server2. I need to know whether this should be done with a master page i.e create the template then each time a new server is added it will create a page based on that template or is there another way which would be better?

Basically MASTER page is used for a common header, footer or left menu purpose. According to your why you think complex. Its easy i think. You can design an aspx page which will be the master page. Then design child page.

In master page you will show the list of available/active servers in a GridView.
When user click on a row then redirect to the child page by the selected server id. In child page select child details by a select statement where serverid=querystring value.

Let me know if you cant understand.

hi,

That is exactly how i have done it so far. Have a sql query on my homepage which returns a list of the servers that the program is monitoring. I have selected the option make them selectable and would like it to take the user to a page depending on which is selected i have done it using gridview code below, however when they are selected nothing happens do i need to put something in the code file to make this happen? are there any good examples

<asp:GridView ID="ListOfServers" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" BorderStyle="Solid" 
            BorderWidth="2px" CaptionAlign="Bottom" CellPadding="4" DataKeyNames="ServerID" 
            DataSourceID="SqlDataSource1" Font-Bold="True" Font-Names="Cordia New" 
            Font-Size="Medium" ForeColor="#333333" HorizontalAlign="Center" 
            ToolTip="This table contains the current list of monitored servers." 
            Width="95%">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="ServerID" HeaderText="ServerID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="ServerID" />
                <asp:BoundField DataField="HostName" HeaderText="HostName" 
                    SortExpression="HostName" />
                <asp:BoundField DataField="MachineType" HeaderText="MachineType" 
                    SortExpression="MachineType" />
                <asp:BoundField DataField="Kernel" HeaderText="Kernel" 
                    SortExpression="Kernel" />
                <asp:BoundField DataField="SerialNo" HeaderText="SerialNo" 
                    SortExpression="SerialNo" />
                <asp:BoundField DataField="PrimaryIP" HeaderText="PrimaryIP" 
                    SortExpression="PrimaryIP" />
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" HorizontalAlign="Center" 
                VerticalAlign="Middle" Wrap="True" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>

YOU CAN ACHIEVE THIS IN THE FOLLOWING WAY:

<asp:TemplateField HeaderText="Action">
                        <ItemTemplate>
                            <asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=frmAgents.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Delete</a>" %>'></asp:Label>
                        </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>

hi,

Where would I put this code. I put it directly after the code I showed you before but it gave errors, do I need to add new controls to the website first? Errors are as follows:

Error	10	'System.Web.UI.Control' does not contain a definition for 'DataItem' and no extension method 'DataItem' accepting a first argument of type 'System.Web.UI.Control' could be found (are you missing a using directive or an assembly reference?)	C:\Users\chris\Documents\work\uni\year3\project\website\Home.aspx	54

Complete code for home page

<%@ Page Language="C#" MasterPageFile="~/Master1.master" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" Title="Site Health Home Page" %>
<%@ MasterType virtualpath="~/Master1.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <h1 style="text-align: center; color: #FFFFFF;">
        <asp:Label ID="CompanyName" runat="server" style="font-size: x-large" 
            Text="Label"></asp:Label>
    </h1>
    <p>
        You are currenlty 
        monitoring 
        <asp:Label ID="serverCount" runat="server" Text="servercount"></asp:Label>
        Solaris Servers:</p>
    <p>
        <asp:GridView ID="ListOfServers" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" BorderStyle="Solid" 
            BorderWidth="2px" CaptionAlign="Bottom" CellPadding="4" DataKeyNames="ServerID" 
            DataSourceID="SqlDataSource1" Font-Bold="True" Font-Names="Cordia New" 
            Font-Size="Medium" ForeColor="#333333" HorizontalAlign="Center" 
            ToolTip="This table contains the current list of monitored servers." 
            Width="95%">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="ServerID" HeaderText="ServerID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="ServerID" />
                <asp:BoundField DataField="HostName" HeaderText="HostName" 
                    SortExpression="HostName" />
                <asp:BoundField DataField="MachineType" HeaderText="MachineType" 
                    SortExpression="MachineType" />
                <asp:BoundField DataField="Kernel" HeaderText="Kernel" 
                    SortExpression="Kernel" />
                <asp:BoundField DataField="SerialNo" HeaderText="SerialNo" 
                    SortExpression="SerialNo" />
                <asp:BoundField DataField="PrimaryIP" HeaderText="PrimaryIP" 
                    SortExpression="PrimaryIP" />
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" HorizontalAlign="Center" 
                VerticalAlign="Middle" Wrap="True" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:sitehealthConnectionString %>" 
            
            SelectCommand="SELECT [ServerID], [HostName], [MachineType], [Kernel], [SerialNo], [PrimaryIP] FROM [T_Servers]" 
            onselecting="SqlDataSource1_Selecting">
        </asp:SqlDataSource>
</p>
         <asp:TemplateField HeaderText="Action">
                        <ItemTemplate>
                            <asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=frmAgents.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Delete</a>" %>'></asp:Label>
                        </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
    <p>
        &nbsp;</p>
<p>
        Site Health Service Status:
        <asp:Label ID="serviceStatusLabel" runat="server" Font-Bold="True" Text="Label" 
            ToolTip="If the service isn't started this application wont work"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="StopService" runat="server" Text="Stop Service" 
            onclick="StopService_Click1" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="StartService" runat="server" Text="Start Service" 
            onclick="StartService_Click1" />
    </p>
    <p>
        &nbsp;</p>
    <p>
        Page Refresh Time
        <asp:DropDownList ID="RefreshTime" runat="server" AppendDataBoundItems="True"  
            AutoPostBack="True" onselectedindexchanged="RefreshTime_SelectedIndexChanged" 
            ToolTip="Sets the refresh time of the current page">
            <asp:ListItem Value="10">10 Seconds</asp:ListItem>
            <asp:ListItem Value="30">30 Seconds</asp:ListItem>
            <asp:ListItem Value="60">60 Seconds</asp:ListItem>
            <asp:ListItem Value="300">5 Minutes</asp:ListItem>
            <asp:ListItem Value="600">10 Minutes</asp:ListItem>
            <asp:ListItem Value="3">3 seconds</asp:ListItem>
            <asp:ListItem Value="5">5 seconds</asp:ListItem>
        </asp:DropDownList>
&nbsp;
        <asp:Label ID="fresh" runat="server" Text="Label"></asp:Label>
    </p>
    <p>
        &nbsp;</p>
    <p>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:sitehealthConnectionString %>" 
            DatasourceMode="DataSet"
            onselecting="SqlDataSource2_Selecting" 
            SelectCommand="SELECT COUNT(*) FROM T_Servers"></asp:SqlDataSource>
    </p>
</asp:Content>

hi im very new to all this any chance you could post the code back with where it should be, i have tried putting it into grid view but still get errors!

hi,

check this

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <h1 style="text-align: center; color: #FFFFFF;">
        <asp:Label ID="CompanyName" runat="server" style="font-size: x-large" 
            Text="Label"></asp:Label>
    </h1>
    <p>
        You are currenlty 
        monitoring 
        <asp:Label ID="serverCount" runat="server" Text="servercount"></asp:Label>
        Solaris Servers:</p>
    <p>
        <asp:GridView ID="ListOfServers" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" BorderStyle="Solid" 
            BorderWidth="2px" CaptionAlign="Bottom" CellPadding="4" DataKeyNames="ServerID" 
            DataSourceID="SqlDataSource1" Font-Bold="True" Font-Names="Cordia New" 
            Font-Size="Medium" ForeColor="#333333" HorizontalAlign="Center" 
            ToolTip="This table contains the current list of monitored servers." 
            Width="95%">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="ServerID" HeaderText="ServerID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="ServerID" />
                <asp:BoundField DataField="HostName" HeaderText="HostName" 
                    SortExpression="HostName" />
                <asp:BoundField DataField="MachineType" HeaderText="MachineType" 
                    SortExpression="MachineType" />
                <asp:BoundField DataField="Kernel" HeaderText="Kernel" 
                    SortExpression="Kernel" />
                <asp:BoundField DataField="SerialNo" HeaderText="SerialNo" 
                    SortExpression="SerialNo" />
                <asp:BoundField DataField="PrimaryIP" HeaderText="PrimaryIP" 
                    SortExpression="PrimaryIP" />
<asp:TemplateField HeaderText="Action">
                        <ItemTemplate>
                            <asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=frmAgents.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Delete</a>" %>'></asp:Label>
                        </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" HorizontalAlign="Center" 
                VerticalAlign="Middle" Wrap="True" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:sitehealthConnectionString %>" 
            
            SelectCommand="SELECT [ServerID], [HostName], [MachineType], [Kernel], [SerialNo], [PrimaryIP] FROM [T_Servers]" 
            onselecting="SqlDataSource1_Selecting">
        </asp:SqlDataSource>
</p>
         
    <p>
        &nbsp;</p>
<p>
        Site Health Service Status:
        <asp:Label ID="serviceStatusLabel" runat="server" Font-Bold="True" Text="Label" 
            ToolTip="If the service isn't started this application wont work"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="StopService" runat="server" Text="Stop Service" 
            onclick="StopService_Click1" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="StartService" runat="server" Text="Start Service" 
            onclick="StartService_Click1" />
    </p>
    <p>
        &nbsp;</p>
    <p>
        Page Refresh Time
        <asp:DropDownList ID="RefreshTime" runat="server" AppendDataBoundItems="True"  
            AutoPostBack="True" onselectedindexchanged="RefreshTime_SelectedIndexChanged" 
            ToolTip="Sets the refresh time of the current page">
            <asp:ListItem Value="10">10 Seconds</asp:ListItem>
            <asp:ListItem Value="30">30 Seconds</asp:ListItem>
            <asp:ListItem Value="60">60 Seconds</asp:ListItem>
            <asp:ListItem Value="300">5 Minutes</asp:ListItem>
            <asp:ListItem Value="600">10 Minutes</asp:ListItem>
            <asp:ListItem Value="3">3 seconds</asp:ListItem>
            <asp:ListItem Value="5">5 seconds</asp:ListItem>
        </asp:DropDownList>
&nbsp;
        <asp:Label ID="fresh" runat="server" Text="Label"></asp:Label>
    </p>
    <p>
        &nbsp;</p>
    <p>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:sitehealthConnectionString %>" 
            DatasourceMode="DataSet"
            onselecting="SqlDataSource2_Selecting" 
            SelectCommand="SELECT COUNT(*) FROM T_Servers"></asp:SqlDataSource>
    </p>
</asp:Content>

Hi,

In the code shown below if you want to pass values to next page containing primary key of the record then change the code to

<asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "ServerID")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=frmAgents.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "ServerID")+ ">Delete</a>" %>'></asp:Label>

hi,

I still get errors do I need something in the server side code?:

Compiler Error Message: CS0103: The name 'ch' does not exist in the current context

Source Error:

 

Line 39: <asp:TemplateField HeaderText="Action">
Line 40:                         <ItemTemplate>
Line 41:                             <asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=frmAgents.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Delete</a>" %>'></asp:Label>
Line 42:                         </ItemTemplate>
Line 43:                             <ItemStyle HorizontalAlign="Center" />

Code is as follows:

<asp:GridView ID="ListOfServers" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" BorderStyle="Solid" 
            BorderWidth="2px" CaptionAlign="Bottom" CellPadding="4" DataKeyNames="ServerID" 
            DataSourceID="SqlDataSource1" Font-Bold="True" Font-Names="Cordia New" 
            Font-Size="Medium" ForeColor="#333333" HorizontalAlign="Center" 
            ToolTip="This table contains the current list of monitored servers." 
            Width="95%">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="ServerID" HeaderText="ServerID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="ServerID" />
                <asp:BoundField DataField="HostName" HeaderText="HostName" 
                    SortExpression="HostName" />
                <asp:BoundField DataField="MachineType" HeaderText="MachineType" 
                    SortExpression="MachineType" />
                <asp:BoundField DataField="Kernel" HeaderText="Kernel" 
                    SortExpression="Kernel" />
                <asp:BoundField DataField="SerialNo" HeaderText="SerialNo" 
                    SortExpression="SerialNo" />
                <asp:BoundField DataField="PrimaryIP" HeaderText="PrimaryIP" 
                    SortExpression="PrimaryIP" />
<asp:TemplateField HeaderText="Action">
                        <ItemTemplate>
                            <asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=frmAgents.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Delete</a>" %>'></asp:Label>
                        </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" HorizontalAlign="Center" 
                VerticalAlign="Middle" Wrap="True" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>

Change DataBinder.Eval(Container.DataItem, "Id") by DataBinder.Eval(Container.DataItem, "ServerID") And change frmagents.aspx to your page.

Always post the error details otherwise it will be difficult for others to identify the problem.

Hi,

I still get the error ch does not exist in the current context does it need to be decalred in the aspx.cs page?:

code now reads:

<asp:Label ID="lblEdit" runat="server" Text='<%# "<a href=frmAgents.aspx?Cmd=EDIT&NavigateId=" + DataBinder.Eval(Container.DataItem, "Id")+ ">Edit</a>"+" | "+ "<a onclick="+ch+"return ConfirmChoice()"+ ch +" href=monitor.aspx?Cmd=DELETE&NavigateId=" + DataBinder.Eval(Container.DataItem, "ServerId")+ ">Delete</a>" %>'></asp:Label>

YES PUT THE LINE public char ch = '"'; just above your page load method like protected void Page_Load(object sender, EventArgs e)

This question has already been answered. Start a new discussion instead.