Note that there are some explanatory texts on larger screens.

plurals
  1. POMaster Pages and Child Pages Setup
    primarykey
    data
    text
    <p>I want to create a Master Page that has a toolbar (add,edit,delete,approve,unapprove) as well as a gridview as shown below. This Master Page will have a lot of children. I want to reused the gridview and the toolbar.. rather than adding both of them to each page i create.</p> <pre><code>&lt;%@ Master Language="VB" AutoEventWireup="false" CodeBehind="JSPSite.master.vb" Inherits="SSPayroll.JSPSite" %&gt; &lt;!DOCTYPE html&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head id="Head1" runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /&gt; &lt;link href="../Styles/Style1.css" rel="stylesheet" type="text/css" /&gt; &lt;asp:ContentPlaceHolder ID="HeadContent" runat="server"&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="Form1" runat="server"&gt; &lt;div class="page"&gt; &lt;div class="header"&gt; &lt;div class="title"&gt; &lt;h1&gt; &lt;asp:Image ID="Image1" runat="server" ImageUrl="~/images/GSCV1.01 - Copy.png" Height="73px" style="margin-top: 20px" Width="428px" /&gt; &lt;/h1&gt; &lt;/div&gt; &lt;div class="loginDisplay"&gt; &lt;asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false"&gt; &lt;LoggedInTemplate&gt; &lt;asp:Label ID="Label2" runat="server" Text="User: " Font-Names="Cambria"&gt;&lt;/asp:Label&gt;&lt;span class="bold"&gt; &lt;asp:LoginName ID="HeadLoginName" runat="server" Font-Names="Cambria" /&gt; &lt;/span&gt; [ &lt;asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/" Font-Names="Cambria" Font-Size="Small" ForeColor="#D9D5D5" Font-Bold="True" LogoutText="Sign Out" /&gt; ] &lt;div&gt; &lt;/div&gt; &lt;/LoggedInTemplate&gt; &lt;RoleGroups&gt; &lt;asp:RoleGroup&gt; &lt;/asp:RoleGroup&gt; &lt;/RoleGroups&gt; &lt;/asp:LoginView&gt; &lt;asp:Label ID="Label1" runat="server" Text="Date/Time" Font-Names="Cambria" Font-Size="Small" ForeColor="#333333"&gt;&lt;/asp:Label&gt; &lt;/div&gt; &lt;div class="clear hideSkiplink"&gt; &lt;asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="False" IncludeStyleBlock="False" Orientation="Horizontal" BackColor="#FFFBD6" DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#990000" StaticSubMenuIndent="10px" Enabled="True"&gt; &lt;DynamicHoverStyle BackColor="#990000" ForeColor="White" /&gt; &lt;DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" /&gt; &lt;DynamicMenuStyle BackColor="#FFFBD6" /&gt; &lt;DynamicSelectedStyle BackColor="#FFCC66" /&gt; &lt;Items&gt; &lt;asp:MenuItem Text="Menu1" Value="Tools"&gt; &lt;asp:MenuItem NavigateUrl="~/JSPayroll/Payment_Rules/PaymentRules.aspx" Text="Payment Rules" Value="Payment Rules"&gt;&lt;/asp:MenuItem&gt; &lt;/asp:MenuItem&gt; &lt;/Items&gt; &lt;StaticHoverStyle BackColor="#990000" ForeColor="White" /&gt; &lt;StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" /&gt; &lt;StaticSelectedStyle BackColor="#FFCC66" /&gt; &lt;/asp:Menu&gt; &lt;/div&gt; &lt;/div&gt; &lt;asp:ContentPlaceHolder ID="ToolBarPlaceHolder" runat="server" &gt; &lt;asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center"&gt; &lt;div&gt; &lt;hr /&gt; &lt;asp:ImageButton ID="ImageButton1" runat="server" Height="48px" ImageUrl="~/IconsPack/Home.png" Width="48px" ToolTip="Home" CssClass="morph" PostBackUrl="~/JSPayroll/JSPDefault.aspx"/&gt; &lt;asp:ImageButton ID="ImageButton2" runat="server" Height="48px" ImageUrl="~/IconsPack/Add.png" PostBackUrl="~/JSPayroll/Payment_Rules/PaymentRulesDetails.aspx" ToolTip="Add Record" CssClass="morph" Width="48px"/&gt; &lt;asp:ImageButton ID="ImageButton3" runat="server" Height="48px" ImageUrl="~/IconsPack/Edit E.png" ToolTip="Edit Record" CssClass="morph" Width="48px" /&gt; &lt;asp:ImageButton ID="ImageButton4" runat="server" Height="48px" ImageUrl="~/IconsPack/ViewDetails.png" ToolTip="View Record Details" CssClass="morph" Width="48px" /&gt; &lt;asp:ImageButton ID="ImageButton5" runat="server" Height="48px" ImageUrl="~/IconsPack/Delete.png" ToolTip="Delete Record" CssClass="morph" Width="48px" /&gt; &lt;asp:ImageButton ID="ImageButton6" runat="server" Height="48px" ImageUrl="~/IconsPack/Approved.png" ToolTip="Approve Record" CssClass="morph" Width="48px"/&gt; &lt;asp:ImageButton ID="ImageButton7" runat="server" Height="48px" ImageUrl="~/IconsPack/Denied.png" ToolTip="Unapprove Record" CssClass="morph" Width="48px"/&gt; &lt;asp:ImageButton ID="ImageButton8" runat="server" Height="48px" ImageUrl="~/IconsPack/Update.png" ToolTip="Refresh Table" CssClass="morph" Width="48px"/&gt; &lt;hr /&gt; &lt;/div&gt; &lt;/asp:Panel&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;asp:ContentPlaceHolder ID="GridViewPlaceHolder" runat="server"&gt; &lt;div class="EU_TableScroll" id="showData" style="display: block"&gt; &lt;asp:GridView ID="GridView1" runat="server" CssClass="EU_DataTable" AllowPaging="True" PageSize="7" AutoGenerateColumns="False" EmptyDataText="No Data Available."&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:CheckBox ID="CheckBox1" runat="server" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/div&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;asp:ContentPlaceHolder ID="DataSource" runat="server"&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;div class="clear"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="footer"&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>An Example of a Child Page using the master page from above.</p> <pre><code>&lt;%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/JSPayroll/JSPSite.Master" CodeBehind="PaymentRules.aspx.vb" Inherits="SSPayroll.PaymentRules" %&gt; &lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="DS" ContentPlaceHolderID ="DataSource" runat ="server"&gt; &lt;asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=sspEntities" DefaultContainerName="sspEntities" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="GeneralRules"&gt; &lt;/asp:EntityDataSource&gt; &lt;/asp:Content&gt; </code></pre> <p>Basically what i want to do is.. In my child page just configure the Data source for each page, attached it to the gridview from the master page and the preform my task.. add, edit, delete (buttons in my master page). I am new to this and dont really have an idea of how to go about this. Some help would be appreciated. Also If someone can tell me what i am doing actually makes sense rather than adding gridviews and toolbar to each page i create. Please let me know. Thank you.</p> <hr> <p>EDITED - With Answer.</p> <hr> <pre><code>Dim ContentPlaceHolder As ContentPlaceHolder Dim gv As GridView ContentPlaceHolder = CType(Master.FindControl("GridViewPlaceHolder"), ContentPlaceHolder) If Not ContentPlaceHolder Is Nothing Then gv = CType(ContentPlaceHolder.FindControl("GridView1"), GridView) If Not gv Is Nothing Then Dim es As EntityDataSource = EntityDataSource1 gv.DataSource = es gv.DataBind() End If End If </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload