Here's my posted code, as simplified as possible:
On the aspx page
--------------------------
<%@ Page Language="C#" MasterPageFile="~/_myTemplate.master"
AutoEventWireup="true"
CodeFile="Entry.aspx.cs" Inherits="Entry" Title="Entry" %>
<%@ Register Assembly="RJS.Web.WebControl.PopCalendar"
Namespace="RJS.Web.WebControl" TagPrefix="rjs" %>
<%@ Register Src="App_Controls/ctlUserNameSelect.ascx"
TagName="ctlUserNameSelect" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain"
runat="Server">
<asp:Literal ID="litList" runat="server" />
<hr />
<br />
<br />
<asp:HiddenField ID="hfUserID" runat="server"
OnInit="hfUserID_Init" />
<asp:HiddenField ID="hfPrivateOrPublic" runat="server" />
<asp:HiddenField ID="hfRequestType" runat="server" />
<br />
<div align="center">
<asp:FormView ID="fvEntry" runat="server"
DataKeyNames="intRequestID" DataSourceID="dsEntry"
DefaultMode="Insert" Height="244px"
OnItemInserted="fvEntry_ItemInserted" OnInit="fvEntry_Init"
OnItemInserting="fvEntry_ItemInserting">
<InsertItemTemplate>
<table align="center" class="inputform">
<tr>
<th colspan="4" style="text-align: center">
<span style="font-size: 11pt">Time Off Request</span>
</th>
</tr>
<tr>
<td style="text-align: right">
<strong>Employee 3/4: </strong>
</td>
<td colspan="3">
<uc1:ctlUserNameSelect ID="ctlUserName" runat="server"
Text='<%# Bind("txtUserName") %>'
OnUserRefresh="ctlUserName_Refresh"
OnLoad="ctlUserName_Load" />
<asp:CustomValidator ID="cvUserValidate" runat="server"
ControlToValidate="ddlRequestType"
ErrorMessage="Incorrect User!" Font-Bold="True"
OnServerValidate= "cvUserValidate_ServerValidate" />
</td>
</tr>
<tr>
<td style="text-align: right; height: 26px;">
<strong>Total Hours:</strong>
</td>
<td style="width: 163px; height: 26px;">
<asp:TextBox ID="txtTotHours" runat="server" Text='<%#
Bind("intTotalHours") %>'
Width="55px" onkeypress="return js_integerOnly_kp
(this)" MaxLength="2" />
<br />
<asp:RequiredFieldValidator ID="rfvTotalHours"
runat="server" ControlToValidate="txtTotHours"
ErrorMessage="Total Hours Required!" Font-Bold="True" /
>
</td>
<td style="width: 80px; text-align: right; height: 26px;">
<strong>Request Type:</strong>
</td>
<td style="height: 26px">
<asp:DropDownList ID="ddlRequestType" runat="server"
DataSourceID="dsRequestType"
DataTextField="txtRequestType"
DataValueField="intRequestTypeID"
OnDataBound="ddlRequestType_DataBound" />
<asp:SqlDataSource ID="dsRequestType" runat="server"
ConnectionString="<%$
ConnectionStrings:HPAS_HumanResourcesConnectionString %>"
SelectCommand="SELECT intRequestTypeID, txtRequestType FROM
tblTimeOffRequestType WHERE (@RequestType = 'Private') OR
(@RequestType = 'Public') AND (blnPrivate = 0)">
<SelectParameters>
<asp:ControlParameter ControlID="hfPrivateOrPublic"
Name="RequestType" PropertyName="Value" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:CustomValidator ID="cvTypeValidate" runat="server"
ControlToValidate="ddlRequestType"
ErrorMessage="Select a Request Type!" Font-Bold="True"
OnServerValidate="cvTypeValidate_ServerValidate" />
</td>
</tr>
<tr>
<td style="text-align: right; height: 47px;">
<strong>Date From:</strong>
</td>
<td style="width: 163px; height: 47px;">
<asp:TextBox ID="txtFromDate" runat="server" Text='<%#
Bind("dteFromDate") %>' Width="103px" />
<rjs:PopCalendar id="pcFrom" runat="server"
Control="txtFromDate" Format="mm dd yyyy"
Separator="/" Font-Bold="True" RequiredDate="True"
RequiredDateMessage="From Date Required!" />
</td>
<td style="text-align: right; width: 80px; height: 47px;">
<strong>Date To:</strong>
</td>
<td style="height: 47px">
<asp:TextBox ID="txtToDate" runat="server" Text='<%# Bind
("dteToDate") %>' Width="103px" />
<rjs:PopCalendar id="pcTo" runat="server"
Control="txtToDate" Format="mm dd yyyy"
Separator="/" Font-Bold="True" RequiredDate="True"
RequiredDateMessage="To Date Required!" />
</td>
</tr>
<tr>
<td colspan="4" align="center">
<div align="center">
<asp:CompareValidator ID="Comp1" runat="server"
ControlToCompare="txtFromDate" ControlToValidate="txtToDate"
ErrorMessage="To Date cannot be less than From
Date!" Font-Bold="True" Operator="GreaterThanEqual" />
</div>
</td>
</tr>
<tr>
<td colspan="4">
<strong><span style="text-decoration: underline">Notes</
span></strong>
<br />
<div align="center">
<asp:TextBox ID="txtEmpNotesTextBox" runat="server"
Text='<%# Bind("txtEmpNotes") %>'
TextMode="MultiLine" Height="90px" Width="479px"
onKeyPress="return limitText(this,5000);"
onPaste="return preventPaste(this,5000);" />
</div>
</td>
</tr>
</table>
<br />
<div align="center">
<asp:ImageButton ID="InsertButton" runat="server"
CommandName="Insert" ImageUrl="~/App_Themes/Images/Submit.jpg" />
<asp:ImageButton ID="InsertCancelButton" runat="server"
CausesValidation="False"
CommandName="Cancel" ImageUrl="~/App_Themes/Images/
Cancel.jpg" OnClick="InsertCancelButton_Click" />
</div>
</InsertItemTemplate>
<ItemTemplate>
<table align="center" class="inputform">
<tr>
<th colspan="4" style="text-align: center">
<span style="font-size: 11pt">Time Off Request</span>
</th>
</tr>
<tr>
<td style="text-align: right">
<strong>Employee 3/4: </strong>
</td>
<td>
<asp:Label ID="lblEmployee" runat="server" Text='<%# Eval
("txtEmployee") %>' />
</td>
<td style="text-align: right">
<strong>Manager: </strong>
</td>
<td>
<asp:Label ID="lblManager" runat="server" Text='<%# Eval
("txtMgr") %>' />
</td>
</tr>
<tr>
<td style="text-align: right;">
<span style="background-color: #f8eede">T</
span><strong>otal Hours:</strong>
</td>
<td>
<asp:Label ID="lblHours" runat="server" Text='<%# Eval
("intTotalHours") %>' />
</td>
<td style="text-align: right;">
<span style="background-color: #f8eede"></
span><strong>Request Type:</strong>
</td>
<td style="height: 26px">
<asp:Label ID="lblRequestType" runat="server" Text='<%#
Eval("txtRequestType") %>' /><strong>
</strong>
</td>
</tr>
<tr>
<td style="text-align: right;">
<strong>Date From:</strong>
</td>
<td>
<asp:Label ID="lblDateFrom" runat="server" Text='<%# Eval
("dteFromDate", "{0:d}") %>' />
</td>
<td style="text-align: right;">
<strong>Date To:</strong>
</td>
<td>
<asp:Label ID="lblDateTo" runat="server" Text='<%# Eval
("dteToDate", "{0:d}") %>' />
</td>
</tr>
<tr>
<td colspan="4">
<strong><span style="text-decoration: underline">Notes</
span></strong>
<br />
<asp:Label ID="lblUserNotes" runat="server"
Height="90px" Text='<%# Eval("txtEmpNotes") %>'
Width="479px" />
</td>
</tr>
<tr>
<td style="text-align: right">
<strong>Requested By:</strong>
</td>
<td>
<asp:Label ID="lblRequestor" runat="server" Text='<%#
Eval("txtRequestor") %>'></asp:Label></td>
<td style="text-align: right">
<strong>Requested On:</strong>
</td>
<td>
<asp:Label ID="lblDateRequested" runat="server" Text='<
%# Eval("dteEnterDate", "{0:d}") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="dsEntry" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$
ConnectionStrings:HPAS_HumanResourcesConnectionString %>"
InsertCommand="INSERT INTO tblTimeOffRequest(txtUserName,
intTotalHours, intRequestTypeID, dteFromDate, dteToDate, txtEmpNotes,
txtEnteredBy, dteEnterDate, blnActive, blnApproved, blnProcessed,
dteProcessDate, txtProcessedBy) VALUES (@txtUserName, @intTotalHours,
@intRequestTypeID, @dteFromDate, @dteToDate, @txtEmpNotes,
@txtEnteredBy, GETDATE(), 1, @blnApproved, @blnProcessed,
@dteProcessDate, @txtProcessedBy)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT Request.intRequestID, [User].txtFullName AS
txtEmployee, ReqType.txtRequestType, Mgr.txtFullName AS txtMgr,
Request.dteFromDate, Request.dteToDate, Request.intTotalHours,
Request.txtEmpNotes, Requestor.txtFullName AS txtRequestor,
Request.dteEnterDate, Request.blnApproved FROM tblTimeOffRequest AS
Request INNER JOIN vwUser AS [User] ON Request.txtUserName =
[User].txtUserName INNER JOIN vwUser AS Requestor ON
Request.txtEnteredBy = Requestor.txtUserName INNER JOIN
vwEmployeeManager AS EmpMgr ON Request.txtUserName = EmpMgr.txtUserID
INNER JOIN vwUser AS Mgr ON EmpMgr.txtManager = Mgr.txtUserName INNER
JOIN tblTimeOffRequestType AS ReqType ON Request.intRequestTypeID =
ReqType.intRequestTypeID WHERE (Request.intRequestID = @CurrentID)"
<InsertParameters>
<asp:Parameter Name="txtUserName" />
<asp:Parameter Name="intTotalHours" />
<asp:ControlParameter ControlID="hfRequestType"
Name="intRequestTypeID" PropertyName="Value"
Type="Int32" />
<asp:Parameter Name="dteFromDate" />
<asp:Parameter Name="dteToDate" />
<asp:Parameter Name="txtEmpNotes" />
<asp:ControlParameter ControlID="hfUserID" Name="txtEnteredBy"
PropertyName="Value" />
<asp:ControlParameter ControlID="hfApproved"
Name="blnApproved" PropertyName="Value" />
<asp:ControlParameter ControlID="hfProcessed"
Name="blnProcessed" PropertyName="Value" />
<asp:ControlParameter ControlID="hfProcessDate"
Name="dteProcessDate" PropertyName="Value" />
<asp:ControlParameter ControlID="hfProcessedBy"
Name="txtProcessedBy" PropertyName="Value" />
</InsertParameters>
<SelectParameters>
<asp:QueryStringParameter Name="CurrentID"
QueryStringField="ID" />
</SelectParameters>
</asp:SqlDataSource>
<asp:HiddenField ID="hfApproved" runat="server" />
<asp:HiddenField ID="hfProcessed" runat="server" />
<asp:HiddenField ID="hfProcessDate" runat="server" />
<asp:HiddenField ID="hfProcessedBy" runat="server" />
</div>
</asp:Content>
On Jul 16, 9:01 am, Cerebrus <[email protected]> wrote:
> What are you storing in the Hidden fields ? Is it something that is
> only available on the client side and your hidden fields are the
> bridge between the client and the server ?
>
> I wouldn't consider 3-6 hidden fields too many, but by the sound of
> it, you should not require any hidden fields unless you are doing some
> sort of custom UI interaction via Javascript. Keep in mind that
> SqlDataSources can accept many different types of parameters.
>
> If you can post a simplified code sample for us to try out, I can try
> to come up with an alternate way to handle this.
>
> On Jul 16, 12:16 am, Chuck <[email protected]> wrote:
>
> > I have a relatively simple question aside from a major application I'm
> > building at work.
>
> > Is there such a thing as having too many hidden fields on an ASP.net
> > page? I currently have 3 now, and may need to pass at least 3 more
> > back to my sqldatasource.
>
> > Just for a little bit of background to what I'm doing: I only ask
> > this as I'm currently using a formview (which, on the
> > insertItemTemplate, has many controls, including an in-house user
> > control) with a sqldatasource attached to it. This formview will be
> > used to enter a request for paid time off, and also will be used for
> > managerial personnel to approve / deny (will be done on the
> > ItemTemplate or EditTemplate). The sqldatasource (to my knowledge)
> > won't pickup the parameters within the formview, unless I tie it to a
> > hidden field (about 3-4 more - depending on how I do my approve / deny
> > options) and do some code-behind tweaking.
>
> > Hopefully, I'm not being too vague with my question. My issue (from
> > what I see) isn't my formview at the moment, as I can set up
> > everything as is. However, if there is a way to pass values
> > dynamically without programmatically casting items in the code behind
> > and sending them through hiddenfields, I'm all ears also. Any
> > clarification would be appreciated.