Accessing controls from a GridView EmptyDataTemplate

    Date: 12/07/05 (Asp Dot Net)    Keywords: css, asp, sql

    FYI: Problem resolved


    Anyone know how I can access controls within the EmptyDataTemplate of my GridView?

    <asp:GridView ID="grdProjectHours" DataSourceID="sqlModifyProjectHours" 
            PageSize="15" AllowPaging=true AllowSorting=true 
            AutoGenerateColumns=false GridLines="Both" 
            ShowFooter=true BorderWidth="2" BorderColor="#000000" 
            runat=server Width="100%" 
            OnDataBound="grdProjectHours_OnDataBound" 
            OnRowUpdating="grdProjectHours_OnRowUpdating" 
            EditRowStyle-VerticalAlign="top">
    	...
    	<Columns>
    		<asp:TemplateField HeaderText="Project" SortExpression="project">
    			...
    		</asp:TemplateField>
    	</Columns>
    	<EmptyDataTemplate>
    		<table width="100%" cellpadding="0" cellspacing="0" border="0">
    			<tr>
    				<td class="gridHeader"><asp:Label ID="lblEmptyProject" runat="server" Text="Project" /></td>
    				<td class="gridHeader"><asp:Label ID="lblEmptyHours" runat="server" Text="Hours" /></td>
    				<td class="gridHeader"><asp:Label ID="lblEmptyWorkDate" runat="server" Text="Date of Work" /></td>
    				<td class="gridHeader"><asp:Label ID="lblEmptyChangeNumber" runat="server" Text="Change Order" /></td>
    				<td class="gridHeader"><asp:Label ID="lblEmptyComments" runat="server" Text="Comments" /></td>
    				<td class="gridHeader"></td>
    			</tr>
    			<tr>
    				<td colspan="7" height="2"></td>
    			</tr>
    			<tr>
    				<td colspan="7" bgcolor="#cccccc"></td>
    			</tr>
    			<tr>
    				<td colspan="7" height="1"></td>
    			</tr>
    			<tr>
    				<td class="gridContent"><asp:DropDownList ID="cboNewProject" Width="225" runat="server" DataSourceID="sqlProject" DataTextField="project" DataValueField="id" OnDataBound="cboNewProject_OnDataBound" /></td>
    				<td class="gridContent"><asp:TextBox ID="txtNewHours" Width="50" runat="server" /></td>
    				<td class="gridContent"><asp:TextBox ID="txtNewWorkDate" Width="50" runat="server" /></td>
    				<td class="gridContent"><asp:TextBox ID="txtNewChangeNumber" MaxLength="10" Width="50" runat="server" /></td>
    				<td class="gridContent"><asp:TextBox ID="txtNewComments" MaxLength="155" Width="100" runat="server" /></td>
    				<td class="gridContent" align="right"><asp:LinkButton ID="btnAddProjectHours" runat="server" CommandName="insert" Text="add" OnClick="btnAddProjectHours_OnClick" /></td>
    			</tr>
    			<tr>
    				<td class="gridContent"><asp:RequiredFieldValidator ID="reqNewProject" ControlToValidate="cboNewProject" ErrorMessage="Project" CssClass="ErrorMessage" EnableClientScript="false" Display="Dynamic" runat="server" /></td>
    				<td class="gridContent"><asp:RequiredFieldValidator ID="reqNewHours" ControlToValidate="txtNewHours" ErrorMessage="Hours" CssClass="ErrorMessage" EnableClientScript="false" Display="Dynamic" runat="server" /></td>
    				<td class="gridContent"><asp:RequiredFieldValidator ID="reqNewWorkDate" ControlToValidate="txtNewWorkDate" ErrorMessage="Date of Work" CssClass="ErrorMessage" EnableClientScript="false" runat="server" /><asp:RangeValidator id="rngWorkDate" runat="server" CssClass="ErrorMessage" ControlToValidate="txtNewWorkDate" MaximumValue="1/1/2100" MinimumValue="1/1/1900" Type="Date" EnableClientScript="false" ErrorMessage="Date of Work (mm/dd/yyyy)" Display="dynamic" /></td>
    				<td class="gridContent"></td>
    				<td class="gridContent"></td>
    				<td class="gridContent" align="right"></td>
    			</tr>
    		</table>
    	</EmptyDataTemplate>
    </asp:GridView>

    Source: http://community.livejournal.com/aspdotnet/50872.html

« SQL Server Question || Retrieving values from... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home