<script type="text/javascript">
function AverageCalculation() {
var TtldgvRows = $("#ContentPlaceHolder1_txtGridviewRows").val();
var MonthValue1 = 0;
var MonthValue2 = 0;
var MonthValue3 = 0;
var percentageValue = 0;
for (var i = 0; i < parseInt(TtldgvRows); i++) {
MonthValue1 = $("#ContentPlaceHolder1_dgvCurrentPerformance_txtMonth1_" + i.toString()).val();
MonthValue2 = $("#ContentPlaceHolder1_dgvCurrentPerformance_txtMonth2_" + i.toString()).val();
MonthValue3 = $("#ContentPlaceHolder1_dgvCurrentPerformance_txtMonth3_" + i.toString()).val();
if (MonthValue1 == "") {
MonthValue1 = 0;
}
if (MonthValue2 == "") {
MonthValue2 = 0;
}
if (MonthValue3 == "") {
MonthValue3 = 0;
}
percentageValue = (parseFloat(MonthValue1) + parseFloat(MonthValue2) + parseFloat(MonthValue3)) / 3;
$("#ContentPlaceHolder1_dgvCurrentPerformance_lblAverage_" + i.toString()).text(percentageValue.toFixed(2));
if (percentageValue > 80) {
$("#ContentPlaceHolder1_dgvCurrentPerformance_imgBtnFileUpload_" + i.toString()).hide();
}
else {
if (parseInt(MonthValue1) != 0 && parseInt(MonthValue2) != 0 && parseInt(MonthValue3) != 0) {
$("#ContentPlaceHolder1_dgvCurrentPerformance_imgBtnFileUpload_" + i.toString()).show();
}
}
}
}
function FileuploadClick() {
var TtldgvRows1 = $("#ContentPlaceHolder1_txtGridviewRows").val();
for (var i = 0; i < parseInt(TtldgvRows1); i++) {
$("#ContentPlaceHolder1_dgvCurrentPerformance_fupCurrentPerformance_" + i.toString()).click();
return;
}
}
function getFile() {
var TtldgvRows1 = $("#ContentPlaceHolder1_txtGridviewRows").val();
var lblFileName;
for (var i = 0; i < parseInt(TtldgvRows1); i++) {
lblFileName = $("#ContentPlaceHolder1_dgvCurrentPerformance_fupCurrentPerformance_" + i.toString()).val();
$("#ContentPlaceHolder1_dgvCurrentPerformance_lblFileUpload_" + i.toString()).text(lblFileName);
}
}
</script>
Gridview控件
<asp:GridView ID="GridView3" runat="server" Width="100%" align="center" HeaderStyle-ForeColor="#4B3333"
HeaderStyle-BackColor="#C4EAC5" PageSize="10" AllowPaging="false" CssClass="table table-bordered table-hover dataTable no-footer Content"
AutoGenerateColumns="false" EmptyDataText="No Record(s) found" DataKeyNames="ID"
OnRowDataBound="dgvCurrentPerformance_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Objective Name" ItemStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lblObjectiveName" runat="server" Style="text-align: center" Text='<%# Eval("ObjectiveName") %>'></asp:Label>
<asp:HiddenField ID="hdnID" runat="server" Value='<%# Eval("ID") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Measurement Name" ItemStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lblMeasurementName" runat="server" Style="text-align: center" Text='<%# Eval("MeasurementName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Target" ItemStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lblTarget" runat="server" Style="text-align: center" Text='<%# Eval("Target") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CA Plan" ItemStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lblCAPlan" Style="text-align: center" runat="server" Text='<%# Eval("CAPlan") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="M1" ItemStyle-Width="15%">
<ItemTemplate>
<asp:TextBox ID="txtMonth1" runat="server" Width="80" CssClass="form-control" Text='<%# Eval("Month1") %>'
onkeypress="return ValidateKeyText(event)" Style="text-align: right;"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="M2" ItemStyle-Width="10%">
<ItemTemplate>
<asp:TextBox ID="txtMonth2" runat="server" Width="80" CssClass="form-control" Text='<%# Eval("Month2") %>'
onkeypress="return ValidateKeyText(event)" Style="text-align: right;"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="M3" ItemStyle-Width="10%">
<ItemTemplate>
<asp:TextBox ID="txtMonth3" runat="server" Width="80" CssClass="form-control" Text='<%# Eval("Month3") %>'
onkeypress="return ValidateKeyText(event)" Style="text-align: right;" onkeyup="AverageCalculation();"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Average" ItemStyle-Width="10%">
<ItemTemplate>
<asp:Label ID="lblAverage" runat="server" Enabled="false" Text="" Style="text-align: center"></asp:Label>
<asp:Image ID="imgBtnFileUpload" runat="server" ImageUrl="Images/upload-button-icon-64365.png"
Width="30px" Height="30px" onclick="FileuploadClick();" ToolTip="Click here to upload"
Style="text-align: right" />
<asp:FileUpload ID="fupCurrentPerformance" runat="server" onchange="getFile();" Style="text-align: center; display: none;" />
<asp:Label ID="lblFileUpload" runat="server" Text=""></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="<center>Action</center>" Visible="false">
<ItemTemplate>
<center>
<asp:LinkButton ID="hylEdit" runat="server" CssClass="fa fa-pencil fa-fw" CausesValidation="false"
ToolTip="Edit" OnClientClick="return Edit();" data-toggle="tooltip" data-placement="top"
title="Edit" OnClick="hylEdit_Click"></asp:LinkButton>
<asp:LinkButton ID="hylDelete" runat="server" CssClass="fa fa-trash-o fa-fw" CausesValidation="false"
ToolTip="Delete" OnClientClick="return Delete();" data-toggle="tooltip" data-placement="top"
title="Delete"></asp:LinkButton>
</center>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="<input id='chkAll' onclick='checkAll();' type='checkbox'>All"
ControlStyle-Width="10%" HeaderStyle-Width="10%">
<ItemTemplate>
<center>
<asp:Label ID="dgvlblIsCurrentPerformance" runat="server" Style="text-align: center;
display: none;" Text='<%# Eval("IsCurrentPerformance")%>'></asp:Label>
<asp:CheckBox ID="chkUserID" runat="server" CssClass="checkbox" onchange="CheckOther();" />
</center>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Measurement ID" ItemStyle-Width="15%" Visible="false">
<ItemTemplate>
<asp:Label ID="lblMeasurementID" runat="server" Text='<%# Eval("MeasurementID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Client ID" ItemStyle-Width="15%" Visible="false">
<ItemTemplate>
<asp:Label ID="lblClientID" runat="server" Text='<%# Eval("ClientID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Objective ID" ItemStyle-Width="15%" Visible="false">
<ItemTemplate>
<asp:Label ID="lblObjectiveID" runat="server" Text='<%# Eval("ObjectiveID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>