Advertisement

03.20.2008 at 09:48PM PDT, ID: 23259126
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Gridview Databound Section is not automatically populating a field value in the gridview footer row

Hello,

I am using the code below to automatically caculate TotalHoursPerUnit after I click the edit button and enter a number in the HeoursPerUnit & PeoplePerUnit fields.  I added a footer row to the Gridview and updated GridView1_RowDataBound to automatically caculate the TotalHoursPerUnit footer row textbox NewTotalHoursPerUnit in the footer row, but no luck.  I do not get an errors.  Any suggestions?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
aspx page
 
<%@ Page Language="VB" MasterPageFile="~/MembersDefault.master" AutoEventWireup="false" CodeFile="frmHR.aspx.vb" Inherits="Members_frmHRBuild" title="HRBuilder" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
    HR Builder<br />
 
<script language =javascript  type="text/javascript">
function Calculate(HoursPerUnit, PeoplePerUnit, TotalHoursPerUnit)
{
    
    TotalHoursPerUnit.value = HoursPerUnit.value * PeoplePerUnit.value;
 
}
   
</script>
 
    <br />
    <asp:LinkButton ID="CheckAll" runat="server">Check All</asp:LinkButton>
    <asp:LinkButton ID="UncheckAll" runat="server">Uncheck All</asp:LinkButton><br />
    &nbsp;<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="DetailMUMID"
        DataSourceID="SqlDataSource1" AllowSorting="True" ShowFooter="True" AllowPaging="True" EmptyDataText="There is not any data.">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:CheckBox ID="RecordSelector" runat="server" />
                </ItemTemplate>
                <EditItemTemplate>
                    &nbsp;
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="DetailID" InsertVisible="False" SortExpression="DetailID">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("DetailID") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label32" runat="server" Text='<%# Bind("DetailID") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:LinkButton ID="AddRecord" runat="server" CommandName="Insert">Add</asp:LinkButton>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="TemplateHRID" SortExpression="TemplateHRID" Visible="False">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox32" runat="server" Text='<%# Bind("TemplateHRID") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label33" runat="server" Text='<%# Bind("TemplateHRID") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="WorkOrderID" SortExpression="WorkOrderID">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox31" runat="server" Text='<%# Bind("WorkOrderID") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label31" runat="server" Text='<%# Bind("WorkOrderID") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="NewWorkOrderID" runat="server"></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Loc" SortExpression="Loc">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="LocddlODS"
                        DataTextField="Loc" DataValueField="Loc">
                    </asp:DropDownList><asp:ObjectDataSource ID="LocddlODS" runat="server" OldValuesParameterFormatString="original_{0}"
                        SelectMethod="GettblLoc" TypeName="tblLocBLL"></asp:ObjectDataSource>
                    &nbsp;
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Loc") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    &nbsp;<asp:DropDownList ID="NewLoc" runat="server" DataSourceID="ddlLoc"
                        DataTextField="Loc" DataValueField="Loc">
                    </asp:DropDownList><asp:SqlDataSource ID="ddlLoc" runat="server" ConnectionString="<%$ ConnectionStrings:HRConnectionString %>"
                        SelectCommand="SELECT [LocID], [Loc] FROM [tblLoc]"></asp:SqlDataSource>
                    &nbsp;
                </FooterTemplate>
            </asp:TemplateField>
                        <asp:TemplateField HeaderText="IndexNumber" SortExpression="IndexNumber">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("IndexNumber") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("IndexNumber") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="NewIndexNumber" runat="server"></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
 
 
            <asp:TemplateField HeaderText="HoursPerUnit" SortExpression="HoursPerUnit">
                <EditItemTemplate>
                    <asp:TextBox ID="tbxHrsPerUnit" runat="server" Text='<%# Bind("HoursPerUnit") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label7" runat="server" Text='<%# Bind("HoursPerUnit") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="NewHoursPerUnit" runat="server"></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
 
 
            <asp:TemplateField HeaderText="PeoplePerUnit" SortExpression="PeoplePerUnit">
                <EditItemTemplate>
                    <asp:TextBox ID="tbxPPerUnit" runat="server" Text='<%# Bind("PeoplePerUnit") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Lbl7" runat="server" Text='<%# Bind("PeoplePerUnit") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="NewPeoplePerUnit" runat="server"></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
 
 
            <asp:TemplateField HeaderText="TotalHoursPerUnit" SortExpression="TotalHoursPerUnit">
                <EditItemTemplate>
                    <asp:TextBox ID="tbxTHrsPerUnit" runat="server" Text='<%# Bind("TotalHoursPerUnit") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Lbl8" runat="server" Text='<%# Bind("TotalHoursPerUnit") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="NewTotalHoursPerUnit" runat="server"></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
 
Code Behind:
------------
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
 
'GridView Edit Template Rows
        Dim HoursPerUnit As System.Web.UI.WebControls.TextBox
        Dim PeoplePerUnit As System.Web.UI.WebControls.TextBox
        Dim TotalHoursPerUnit As System.Web.UI.WebControls.TextBox
  
 
If e.Row.RowType = DataControlRowType.DataRow AndAlso e.Row.RowState = DataControlRowState.Edit Then
 
            HoursPerUnit = CType(e.Row.FindControl("tbxHrsPerUnit"), System.Web.UI.WebControls.TextBox)
            PeoplePerUnit = CType(e.Row.FindControl("tbxPPerUnit"), System.Web.UI.WebControls.TextBox)
            TotalHoursPerUnit = CType(e.Row.FindControl("tbxTHrsPerUnit"), System.Web.UI.WebControls.TextBox)
 
            HoursPerUnit.Attributes.Add("onchange", "Calculate(" + HoursPerUnit.ClientID + "," + PeoplePerUnit.ClientID + "," + TotalHoursPerUnit.ClientID + ")")
            PeoplePerUnit.Attributes.Add("onchange", "Calculate(" + HoursPerUnit.ClientID + "," + PeoplePerUnit.ClientID + "," + TotalHoursPerUnit.ClientID + ")")
 
        End If
 
'Gridview Footer Row    'Nothing happens when using the statements 
 
If e.Row.RowType = DataControlRowType.DataRow AndAlso e.Row.RowState = DataControlRowState.Insert Then
 
  
 
'   HoursPerUnit = CType(Me.GridView1.FooterRow.FindControl("NewHoursPerUnit"), System.Web.UI.WebControls.TextBox)
 
'   PeoplePerUnit = CType(Me.GridView1.FooterRow.FindControl("NewPeoplePerUnit"), System.Web.UI.WebControls.TextBox)
 
'   TotalHoursPerUnit = CType(Me.GridView1.FooterRow.FindControl("NewTotalHoursPerUnit"), System.Web.UI.WebControls.TextBox)
 
HoursPerUnit = CType(e.Row.FindControl("NewHoursPerUnit"), System.Web.UI.WebControls.TextBox)
PeoplePerUnit = CType(e.Row.FindControl("NewPeoplePerUnit"), System.Web.UI.WebControls.TextBox)
TotalHoursPerUnit = CType(e.Row.FindControl("NewTotalHoursPerUnit"), System.Web.UI.WebControls.TextBox)
 
 
HoursPerUnit.Attributes.Add("onchange", "Calculate(" + HoursPerUnit.ClientID + "," + PeoplePerUnit.ClientID + "," + TotalHoursPerUnit.ClientID + ")")
 
PeoplePerUnit.Attributes.Add("onchange", "Calculate(" + HoursPerUnit.ClientID + "," + PeoplePerUnit.ClientID + "," + TotalHoursPerUnit.ClientID + ")")
 
 
 
End If
 
    End Sub
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: cesemj
Solution Provided By: MaxOvrdrv2
Participating Experts: 2
Solution Grade: A
Views: 43
Translate:
Loading Advertisement...
03.20.2008 at 10:11PM PDT, ID: 21178301

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.20.2008 at 11:03PM PDT, ID: 21178417

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.21.2008 at 12:22AM PDT, ID: 21178568

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.21.2008 at 04:14AM PDT, ID: 21179110

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.21.2008 at 07:13AM PDT, ID: 21179981

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.21.2008 at 07:58AM PDT, ID: 21180339

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.21.2008 at 08:28AM PDT, ID: 21180577

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.21.2008 at 10:51PM PDT, ID: 21184929

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.28.2008 at 06:25PM PDT, ID: 21235072

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628