I am developing a ASP.NET web application. One of my from perform very slow in client machine. Where I use GridView which include some function and some control on there like combo-box input box, each control have some function and calculation on there leave.
Please suggest me how can I improve this?
Page on content.
- GridView
1. Combobox with jquery datafiltering
2. Inputbox with data check function
3. More function of grid like update,add, new, delete.
I am also use Viewsate on this page.
<%# Page Title="" Language="C#" MasterPageFile="~/UI/Healthcare.Master" AutoEventWireup="true" CodeBehind="frmStockIn.aspx.cs" Inherits="Com.Codespecies.Healthcare.UI.Pharmacy.frmStockIn" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder_header" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
...........
....
....
<div class="box_bg" style="height: auto; width: 1020px; border: 0px solid; border-color: #0167AA; margin:5px 0px 0px 0px; float:left;">
<div style=" min-height:30px; width: 1005px; padding: 0px 0px 0px 2px;">
<div style="min-height: 30px; width:auto; width:300px; float: left; font-weight: bold;">
Drugs Details
</div>
<div style="min-height: 30px; width: 600px; float: left;">
<div id="msg" style="height:auto; float:left;">
<asp:Label ID="lblMsg" runat="server" Text=" "></asp:Label>
</div>
<div id="ajaxLoader" style=" display:none; margin:2px 0px 0px 0px; float:left;">
<img height="20px" width="20px" src="../../image/ajax-loading/ajax-loading-2.gif" alt="loader" border="0" style=""/>
</div>
</div>
</div>
<div style=" width: auto; padding: 0px 0px 5px 0px;">
<asp:GridView ID="gvStockIn" runat="server" AllowPaging="True" Width="1020px"
AlternatingRowStyle-HorizontalAlign="Left" AlternatingRowStyle-VerticalAlign="Middle"
AutoGenerateColumns="False" BorderStyle="None" DataKeyNames="ID"
Font-Names="Calibri" Font-Size="Small" ForeColor="#333333" GridLines="None"
PageSize="100" ShowFooter="True" ShowHeaderWhenEmpty="True"
onrowcancelingedit="gvStockIn_RowCancelingEdit" onrowcommand="gvStockIn_RowCommand"
onrowdeleting="gvStockIn_RowDeleting" onrowediting="gvStockIn_RowEditing"
onrowupdating="gvStockIn_RowUpdating" onrowdatabound="gvStockIn_RowDataBound"
AllowSorting="True" TabIndex="5">
<AlternatingRowStyle BackColor="#DCEEFC" Font-Names="Calibri" HorizontalAlign="Left" VerticalAlign="Middle" />
<Columns>
<asp:TemplateField HeaderText="SL" SortExpression="ID">
<ItemStyle Width="30px" />
<HeaderStyle Width="30px" />
<FooterStyle Width="30px" />
<EditItemTemplate>
<asp:Label ID="lblSerialNo" runat="server" Text='<%# Eval("ID") %>' Width="30px"></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="lblNewSerialNo" runat="server" Width="30px">NA</asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblSerialNo" runat="server" Text='<%# Bind("ID") %>' Width="30px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Drug" >
<ItemStyle Width="170px" />
<HeaderStyle Width="170px" />
<FooterStyle Width="170px" />
<EditItemTemplate>
<asp:Label ID="lblDrug" runat="server" Text='<%# Bind("DRUG_NAME") %>' Width="170px"></asp:Label>
<%--<asp:TextBox ID="txtDrug" runat="server" CssClass="Drug" Text='<%# Eval("DRUG_NAME") %>' Width="100px"></asp:TextBox>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList CssClass="fire_selected_change_event combobox combobox1" ID="ddlNewDrug" runat="server" onselectedindexchanged="ddlNewDrug_SelectedIndexChanged">
</asp:DropDownList>
<%--<asp:TextBox ID="txtNewDrug" runat="server" CssClass="Drug" Width="100px"></asp:TextBox>--%>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblDrug" runat="server" Text='<%# Bind("DRUG_NAME") %>' Width="170px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Presentation">
<ItemStyle Width="130px" />
<HeaderStyle Width="130px" />
<FooterStyle Width="130px" CssClass="drug_list1"/>
<EditItemTemplate>
<asp:Label ID="lblPresentation" runat="server" Text='<%# Bind("PRESENTATION_NAME") %>' Width="130px"></asp:Label>
<%--<asp:TextBox ID="txtPresentation" runat="server" CssClass="Presentation" Text='<%# Eval("PRESENTATION_NAME") %>' Width="110px"></asp:TextBox>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList CssClass="fire_selected_change_event combobox combobox1" ID="ddlNewPresentation" runat="server" AutoPostBack="True" onselectedindexchanged="ddlNewPresentation_SelectedIndexChanged">
</asp:DropDownList>
<%--<asp:TextBox ID="txtNewPresentation" runat="server" CssClass="Presentation" Width="110px"></asp:TextBox>--%>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblPresentation" runat="server" Text='<%# Bind("PRESENTATION_NAME") %>' Width="130px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Unit Strength">
<ItemStyle Width="130px" />
<HeaderStyle Width="130px" />
<FooterStyle Width="130px" CssClass="drug_list1"/>
<EditItemTemplate>
<asp:Label ID="lblUnitStrength" runat="server" Text='<%# Bind("DRUG_UNIT_STRENGTH") %>' Width="110px"></asp:Label>
<%--<asp:TextBox ID="txtUnitStrength" runat="server" CssClass="UnitStrength" Text='<%# Eval("DRUG_UNIT_STRENGTH") %>' Width="110px"></asp:TextBox>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList CssClass="fire_selected_change_event combobox combobox1" ID="ddlNewUnitStrength" runat="server" AutoPostBack="True" onselectedindexchanged="ddlNewUnitStrength_SelectedIndexChanged">
</asp:DropDownList>
<%--<asp:TextBox ID="txtNewUnitStrength" runat="server" CssClass="UnitStrength" Width="110px"></asp:TextBox>--%>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblUnitStrength" runat="server" Text='<%# Bind("DRUG_UNIT_STRENGTH") %>' Width="110px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mfg Date">
<ItemStyle Width="65px" />
<HeaderStyle Width="65px" />
<FooterStyle Width="65px" />
<EditItemTemplate>
<asp:TextBox ID="txtManufacturerDate" runat="server" CssClass="date_property" Text='<%# Eval("DRUG_MANUFACTURER_DATE", "{0:dd/MM/yyyy}") %>' Height="25px" Width="65px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewManufacturerDate" runat="server" CssClass="date_property" Height="25px" Width="65px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblManufacturerDate" runat="server" Text='<%# Bind("DRUG_MANUFACTURER_DATE", "{0:dd/MM/yyyy}") %>' Height="25px" Width="65px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Exp. Date">
<ItemStyle Width="65px" />
<HeaderStyle Width="65px" />
<FooterStyle Width="65px" />
<EditItemTemplate>
<asp:TextBox ID="txtExpireDate" runat="server" CssClass="date_property" Text='<%# Eval("DRUG_EXPIRE_DATE", "{0:dd/MM/yyyy}") %>' Height="25px" Width="65px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewExpireDate" runat="server" CssClass="date_property" Height="25px" Width="65px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblExpireDate" runat="server" Text='<%# Bind("DRUG_EXPIRE_DATE", "{0:dd/MM/yyyy}") %>' Height="25px" Width="65px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Qty">
<ItemStyle Width="40px" HorizontalAlign="Right" />
<HeaderStyle Width="40px" HorizontalAlign="Right" />
<FooterStyle Width="40px" HorizontalAlign="Right" />
<EditItemTemplate>
<asp:TextBox ID="txtQuantity" runat="server" CssClass="check_decimal Quantity" Text='<%# Eval("QUANTITY") %>' Height="25px" Width="40px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewQuantity" runat="server" CssClass="check_decimal Quantity" Height="25px" Width="40px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblQuantity" runat="server" Text='<%# Bind("QUANTITY") %>' Height="25px" Width="40px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Cost Price">
<ItemStyle Width="70px" HorizontalAlign="Right"/>
<HeaderStyle Width="70px" HorizontalAlign="Right"/>
<FooterStyle Width="70px" HorizontalAlign="Right"/>
<EditItemTemplate>
<asp:TextBox ID="txtCostPrice" runat="server" CssClass="check_decimal CostPrice" Text='<%# Eval("COST_PRICE") %>' ontextchanged="txtCostPrice_TextChanged" AutoPostBack="true" Height="25px" Width="60px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewCostPrice" runat="server" CssClass="check_decimal CostPrice" ontextchanged="txtNewCostPrice_TextChanged" AutoPostBack="true" Height="25px" Width="60px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblCostPrice" runat="server" Text='<%# Bind("COST_PRICE") %>' Height="25px" Width="60px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sale Price">
<ItemStyle Width="70px" HorizontalAlign="Right"/>
<HeaderStyle Width="70px" HorizontalAlign="Right"/>
<FooterStyle Width="70px" HorizontalAlign="Right"/>
<EditItemTemplate>
<asp:TextBox ID="txtSellPrice" runat="server" CssClass="check_decimal SellPrice" Text='<%# Eval("SELL_PRICE") %>' Height="25px" Width="60px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewSellPrice" runat="server" CssClass="check_decimal SellPrice" Height="25px" Width="60px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblSellPrice" runat="server" Text='<%# Bind("SELL_PRICE") %>' Height="25px" Width="60px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Discount">
<ItemStyle Width="60px" HorizontalAlign="Right"/>
<HeaderStyle Width="60px" HorizontalAlign="Right"/>
<FooterStyle Width="60px" HorizontalAlign="Right"/>
<EditItemTemplate>
<asp:TextBox ID="txtDiscount" runat="server" CssClass="check_decimal percentage" Text='<%# Eval("DISCOUNT") %>' Height="25px" Width="60px"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewDiscount" runat="server" CssClass="check_decimal percentage" Height="25px" Width="60px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblDiscount" runat="server" Text='<%# Bind("DISCOUNT") %>' Height="25px" Width="60px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sub Total">
<ItemStyle Width="70px" HorizontalAlign="Right"/>
<HeaderStyle Width="70px" HorizontalAlign="Right"/>
<FooterStyle Width="70px" HorizontalAlign="Right"/>
<EditItemTemplate>
<asp:TextBox ID="txtSubTotal" runat="server" CssClass="check_decimal" Text='<%# Eval("SUB_TOTAL_AMOUNT") %>' ontextchanged="txtSubTotal_TextChanged" AutoPostBack="true" Height="25px" Width="70px"></asp:TextBox>
<%--<asp:Label ID="lblSubTotal" runat="server" Text='<%# Eval("SUB_TOTAL_AMOUNT") %>' Height="25px" Width="80px"></asp:Label>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewSubTotal" runat="server" CssClass="check_decimal" Text='' ontextchanged="txtNewSubTotal_TextChanged" AutoPostBack="true" Height="25px" Width="70px"></asp:TextBox>
<%--<asp:Label ID="lblSubTotal" runat="server" Text='' Height="25px" Width="80px"></asp:Label>--%>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblSubTotal" runat="server" Text='<%# Bind("SUB_TOTAL_AMOUNT") %>' Height="25px" Width="70px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action" ShowHeader="False">
<ItemStyle Width="100px" HorizontalAlign="Center"/>
<HeaderStyle Width="100px" HorizontalAlign="Center"/>
<FooterStyle Width="100px" HorizontalAlign="Center"/>
<EditItemTemplate>
<asp:ImageButton ID="lnkUpdate" ToolTip="Update" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/update.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="Update" ></asp:ImageButton>
<asp:ImageButton ID="lnkCancel" ToolTip="Cancel" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/cancel.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="Cancel" ></asp:ImageButton>
<%-- <asp:LinkButton ID="lnkUpdate" runat="server" CausesValidation="False" OnClientClick="load_ajax_drugs_details();" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="False" OnClientClick="load_ajax_drugs_details();" CommandName="Cancel" Text="Cancel"></asp:LinkButton>--%>
</EditItemTemplate>
<FooterTemplate>
<asp:ImageButton ID="lnkNew" ToolTip="New" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/add.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="New" ></asp:ImageButton>
<asp:ImageButton ID="lnkRefresh" ToolTip="Refresh" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/refresh.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="Refresh" ></asp:ImageButton>
</FooterTemplate>
<ItemTemplate>
<asp:ImageButton ID="lnkEdit" ToolTip="Edit" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/edit.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="Edit" ></asp:ImageButton>
<%--<asp:LinkButton ID="lnkEdit" ToolTip="Edit" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/edit.png" Height="10px" Width="15px" CausesValidation="False" CommandArgument="" CommandName="Edit" Text="Edit"></asp:LinkButton>--%>
<asp:ImageButton ID="lnkDelete" ToolTip="Delete" runat="server" OnClientClick="load_ajax_drugs_details();" ImageUrl="../../image/delete.png" Height="25px" Width="25px" CausesValidation="False" CommandArgument="" CommandName="Delete" ></asp:ImageButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#507CD1" ForeColor="White" HorizontalAlign="Left" VerticalAlign="Middle" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Right" VerticalAlign="Middle" />
<RowStyle Font-Names="Calibri" />
<FooterStyle CssClass="drug_list"></FooterStyle>
</asp:GridView>
</div>
.....
.....
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
}
There is a lot of reasons for this issue.As far as i under stood from your question I will suggest some places where you need to take a look at.
1)Check how much data you retrieves from database in order to show the gridview primarily.
2)adding the above controls to the gridview won't make it perform badly.But the calculations you where talking about may be a cause.Take a deep look at the code ,check whether there is any long running loops or some thing else is there.
3)if the first two is not helping you make a profiling.For your problem you just need a trial version of ants performance profiler.
After installing the profile find out which database call or .net function is taking more time to execute then debug it.
Related
please excuse this potentially long post as I feel like most of the information I will add below is necessary. As the title states I am trying to loop through a collection of controls that are within a gridview on my page (there are 2 gridviews actually, but they are identical in behavior) and store the values of some of these controls in an array that I can use to perform other functions.
To start I have added the code for the gridview below.
<asp:Panel ID="gridPNL1" runat="server">
Repair / Labor<asp:LinkButton runat="server" ID="lbAddRepair" Text="Add New Repair / Labor" CommandName="AddLabor" OnClick="AddObject_Click" Enabled="false" style="margin-left:20px" Visible="false" />
<asp:GridView ID="GridView1" runat="server"
EmptyDataText="No Claimed Labor" AutoGenerateColumns="False"
ShowHeaderWhenEmpty="True" DataKeyNames="RecID"
ShowFooter="True" DataSourceID="SqlDataSource6" Width="95%">
<RowStyle HorizontalAlign="Center" />
<EmptyDataTemplate>
<asp:DropDownList ID="ddlRepairEquipmentNew" runat="server" DataSourceID="SqlDataSourcePartEquipment" DataValueField="RecID"
DataTextField="EquipmentPart" AppendDataBoundItems="True" AutoPostBack="True" Width="220px" Height="20px"
Style="margin-left: 70px;" > <%-- Removed the OnSelectedIndexChanged (add if needed) --%>
<asp:ListItem Value ="0">---SELECT---</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlRepairNew" runat="server" DataSourceID="SqlDataSourceRepair" DataValueField="RecID"
DataTextField="Description" AppendDataBoundItems="True" Width="220px" Height="20px" AutoPostBack="true"
style="" OnSelectedIndexChanged="ddlRepairNew_SelectedIndexChanged"
OnDataBinding="ddlRepairNew_DataBinding">
<asp:ListItem Value="0">---SELECT---</asp:ListItem>
</asp:DropDownList>
<%-- <asp:textbox ID="txtDescOther" runat="server" Width="235px" Visible="false" />--%>
<asp:textbox runat="server" ID="txtRepairHoursNew" Width="95px" style="margin-left: 68px"/>
<%--<asp:Label runat="server" ID="lblRepairHoursAllowed"></asp:Label>--%>
<asp:HiddenField runat="server" ID="hidAllowedRepairHoursNew" />
<%-- <asp:textbox ID="txtAllowedHoursNew" runat="server" Width="90px"/>--%>
<asp:textbox ID="txtRepairCostNew" runat="server" Width="95px" ReadOnly="True"/>
<asp:textbox ID="txtLineTotalNew" runat="server" Width="95px" ReadOnly="true"/>
<asp:textbox ID="txtTaxNew" runat="server" Width="95px" text="0"/>
<asp:Button ID="InsertDetail" runat="server" CommandName="InsertDetail" Height="25px" Text="Add Detail" Width="85px" />
</EmptyDataTemplate>
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:CommandField ShowEditButton="True" footertext="Add -->" ShowDeleteButton="True" HeaderStyle-Width="70px"/>
<asp:BoundField DataField="RecID" HeaderText="RecID" SortExpression="RecID" ReadOnly="True" Visible="False" />
<asp:TemplateField HeaderText="Equipment / Repair / Labor Description" ItemStyle-HorizontalAlign="center" >
<ItemTemplate>
<asp:Label ID="lblRepairEquipmentType" Text='<%# Bind("EquipmentType") %>' runat="server" Enabled="False" Width="220px" />
<asp:label ID="lblRepairType" Text='<%# Bind("RepairType") %>' runat="server" Enabled="False" Width="220px"/>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlRepairEquipmentEdit" runat="server" DataSourceID="SqlDataSourcePartEquipment" DataValueField="RecID" DataTextField="EquipmentPart" SelectedValue='<%# Eval("EquipmentID") %>' AppendDataBoundItems="True" AutoPostBack="True" Width="220px" Height="20px" >
<asp:ListItem Value="0">---SELECT---</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlRepairEdit" runat="server" DataSourceID="SqlDataSourceRepair" DataValueField="RecID" DataTextField="Description" SelectedValue='<%# Eval("RepairID")%>' AppendDataBoundItems="True" AutoPostBack="true" Width="220px" Height="20px" OnSelectedIndexChanged="ddlRepairEdit_SelectedIndexChanged" />
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlRepairEquipmentInsert" runat="server" DataSourceID="SqlDataSourcePartEquipment" DataValueField="RecID" DataTextField="EquipmentPart" AppendDataBoundItems="True" AutoPostBack="True" Width="220px" Height="20px" Style="margin-left: 29px" >
<asp:ListItem Value="0">---SELECT---</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="ddlRepairInsert" runat="server" DataSourceID="SqlDataSourceRepair" DataValueField="RecID" DataTextField="Description" AppendDataBoundItems="True" autopostback="true" Width="220px" Height="20px" OnSelectedIndexChanged="ddlRepairInsert_SelectedIndexChanged" OnDataBinding="ddlRepairInsert_DataBinding">
<asp:ListItem Value="0">---SELECT---</asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Repair Hours Requested" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:label ID="lblRepairHours" Text='<%# Bind("RepairHours")%>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:textbox ID="txtRepairHoursEdit" Text='<%# Bind("RepairHours")%>' runat="server" Width="95px" />
<%--<asp:Label ID="lblRepairHoursEdit" runat="server"></asp:Label>--%>
<asp:HiddenField runat="server" ID="hidAllowedRepairHoursEdit" Value='<%# Bind("AllowedHours")%>' />
</EditItemTemplate>
<FooterTemplate>
<asp:textbox ID="txtRepairHoursInsert" runat="server" style="width: 100%; box-sizing: border-box;"/>
<%--<center><asp:Label ID="lblRepairHoursInsert" runat="server"></asp:Label></center>--%>
<asp:HiddenField runat="server" ID="hidAllowedRepairHoursInsert" />
</FooterTemplate>
</asp:TemplateField>
<%--<asp:TemplateField HeaderText="Repair Hours Approved" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:label ID="lblAllowedHours" Text='<%# Bind("AllowedHours")%>' runat="server" Width="50px"/>
</ItemTemplate>
<EditItemTemplate>
<asp:textbox ID="txtAllowedHoursEdit" Text='<%# Bind("AllowedHours")%>' Enabled="true" runat="server" Width="50px"/>
</EditItemTemplate>
<FooterTemplate>
<asp:textbox ID="txtAllowedHoursInsert" Text='<%# Bind("AllowedHours")%>' runat="server" style="width: 100%; box-sizing: border-box;"/>
</FooterTemplate>
</asp:TemplateField>--%>
<asp:TemplateField HeaderText="Repair Cost" ItemStyle-HorizontalAlign="center" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:label ID="lblRepairCost" Text='<%# Bind("RepairCost", "{0:C}") %>' runat="server" Enabled="False"/>
</ItemTemplate>
<EditItemTemplate>
<asp:textbox ID="txtRepairCostEdit" Text='<%# Bind("RepairCost") %>' runat="server" ReadOnly="True" Width="95px"/>
</EditItemTemplate>
<FooterTemplate>
<asp:textbox ID="txtRepairCostInsert" Text='<%# Bind("RepairCost") %>' runat="server" ReadOnly="True" style="width: 100%; box-sizing: border-box;"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Repair Total" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:label ID="lblRepairTotal" Text='<%# Bind("LaborRequested", "{0:C}")%>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:textbox ID="txtRepairTotalEdit" Text='<%# Bind("LaborRequested")%>' Enabled="false" runat="server" Width="95px"/>
</EditItemTemplate>
<FooterTemplate>
<asp:textbox ID="txtRepairTotalInsert" Text='<%# Bind("LaborRequested") %>' runat="server" Enabled="false" style="width: 100%; box-sizing: border-box;"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Tax" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:LinkButton ID="lbTaxTotal" Text='<%# Bind("Tax", "{0:C}")%>' runat="server" CommandArgument="Repair" OnClick="lblTaxTotal_Click" />
<asp:HiddenField ID="hidRepairGST" runat="server" Value='<%# Bind("GST")%>' />
<asp:HiddenField ID="hidRepairPST" runat="server" Value='<%# Bind("PST")%>' />
<asp:HiddenField ID="hidRepairQST" runat="server" Value='<%# Bind("QST")%>' />
<asp:HiddenField ID="hidRepairHST" runat="server" Value='<%# Bind("HST")%>' />
</ItemTemplate>
<EditItemTemplate>
<asp:textbox ID="lblTaxTotalEdit" Text='<%# Bind("Tax")%>' Enabled="true" runat="server" Width="95px"/>
</EditItemTemplate>
<FooterTemplate>
<asp:textbox ID="txtTaxTotalInsert" runat="server" Enabled="true" text="0" style="width: 100%; box-sizing: border-box;"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Insert New" HeaderStyle-Width="85px">
<ItemTemplate>
<asp:Label ID="lblEmpty" Text="" runat="server" Width="85px"/>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="Insert" runat="server" CommandName="InsertNewDetail" Height="22px" Text="Insert" style="width: 100%; box-sizing: border-box;" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#336699" ForeColor="White" />
</asp:GridView>
<asp:Label runat="server" ID="lblErrorRepair" ForeColor="Red" />
<br />
</asp:Panel>
What I am trying to do with the gridview above is loop through some specific controls on the gridview and store their values in an array. Essentially how this gridview works is the user will enter information into a series of drop down lists and textboxes, as seen above, when the user hits the button at the end of the row (labeled "InsertDetail" and "Insert" respectively, it takes the data from the drop down list and textboxes and stores it in the labels (also above) for simpler display (this goes on for however many items the user needs to enter (usually around 2 - 5 items total)). I need a way to loop through the values in however many iterations of "lblRepairEquipmentType" there are at the time the user hits any of the "insert" buttons and store the value of each iteration of "lblRepairEquipmentType" in an array so that I can use that array to perform other procedures.
Any help would be greatly appreciated and if there is something else I can try that would be better, either efficiency wise or just for best practices I would appreciate and welcome any constructive criticism. Thank you all for your patience and willingness to help.
I have a Page Fruit that has a UpdatePanel P1 and a ModalWIndow (outside of the updatepanel). I have a Page Apple with An UpdatePanel P2. ModalWindow on Page fruit will add Page Apple on demand.
Now, In the Apple Page
I have a GridView with EditItemTemplate and FooterItemtemplate for lets say 5 columns. Both of them have RegularExpressionValidator and RequiredFieldValidtor each separated by ValidationGroup. For EditItemTemplate everything is on point.
For FooterItemTemplate, the button won't do postback even though all the validation is met.
The footer template looks like this for the column of interest
<FooterTemplate>
<asp:TextBox ID="vendorAdd" runat="server" Width="95%"/>
<asp:RegularExpressionValidator ID="RegularExpressionValidator66" ControlToValidate="vendorAdd" ValidationGroup="AddValidation"
ValidationExpression="\w*" runat="server" ErrorMessage="Invalid VendorName" />
<asp:RequiredFieldValidator id = "RegularExpressionValidator67" ValidationGroup="AddValidation" ControlToValidate="vendorAdd"
runat="server" ErrorMessage="VendorName Required" />
</FooterTemplate>
There is no message saying this failed. I removed the all the other validation on other footer column than shown above. I added on the button to stop validation. And in Server side added this
Page.Validate("AddValidation");
var b = Page.IsValid;
var notValidValidators = Page.Validators.Cast<IValidator>().Where(v => !v.IsValid);`
Here in the debugger the notValidValidator says that RequiredFieldValidator is not Valid. I don't see why though, I have a value and there is no message on the front end.
Update Panel on Apple Page full Code is below
<asp:UpdatePanel ID="ackPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="ackedItems" runat="server" Width="720" Visible="true" DataKeyNames="AckId" RowStyle-Height="10px"
AutoGenerateColumns="False" BorderStyle="Dotted" BorderWidth="1px" CellPadding="2"
BackColor="White" BorderColor="#CCCCCC" HorizontalAlign="Left" AllowPaging="false"
ShowFooter="true" OnRowUpdating="AckedItems_RowUpdating" OnRowDeleting="AckedItems_RowDeleting"
OnRowEditing="AckedItems_RowEditing" OnRowCommand="AckedItems_RowCommand" OnRowDataBound="AckedItems_RowDataBound">
<RowStyle ForeColor="#000066" Font-Size="8pt" />
<HeaderStyle ForeColor="#336699" Font-Size="8pt" CssClass="GridViewHeader" Height="20px" />
<AlternatingRowStyle CssClass="GridViewAltStyle" />
<Columns >
<asp:BoundField DataField="AckId" ReadOnly="true" Visible="false" />
<asp:TemplateField HeaderText="Vendor" HeaderStyle-Width="10%">
<ItemTemplate>
<asp:Label ID="vendor" runat="server" Text='<%# Bind("VendorName") %>' Width="95%"/>
</ItemTemplate>
<EditItemTemplate >
<asp:TextBox ID="vendorEdit" runat="server" Text='<%# Bind("VendorName") %>' Width="95%"/>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="vendorEdit" ValidationGroup="EditValidation"
ValidationExpression="\w*" runat="server" ErrorMessage="Invalid VendorName" />
<asp:RequiredFieldValidator id = "Ab" ValidationGroup="EditValidation" ControlToValidate="vendorEdit"
runat="server" ErrorMessage="VendorName Required" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="vendorAdd" runat="server" Width="95%"/>
<asp:RegularExpressionValidator ID="RegularExpressionValidator66" ControlToValidate="vendorAdd" ValidationGroup="AddValidation"
ValidationExpression="\w*" runat="server" ErrorMessage="Invalid VendorName" />
<asp:RequiredFieldValidator id = "RegularExpressionValidator67" ValidationGroup="AddValidation" ControlToValidate="vendorAdd"
runat="server" ErrorMessage="VendorName Required" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount" HeaderStyle-Width="10px">
<ItemTemplate>
<asp:Label ID="amount" DataFormatString = "{0:C2}" runat="server" Text='<%# Bind("Amount") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="amountEdit" runat="server" Text='<%# Bind("Amount") %>' Width="95%"/>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" ControlToValidate="amountEdit" ValidationGroup="EditValidation"
ValidationExpression="\d*(\.\d*)?" runat="server" ErrorMessage="Invalid Amount" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="EditValidation" ControlToValidate="amountEdit"
runat="server" ErrorMessage="Amount Required" />
</EditItemTemplate>
<FooterTemplate >
<asp:TextBox ID="amountAdd" runat="server"
Width="95%" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator4" ControlToValidate="amountAdd" ValidationGroup="AddValidation"
ValidationExpression="\d*(\.\d*)?" runat="server" ErrorMessage="Invalid Amount" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type">
<ItemTemplate>
<asp:Label ID="type" runat="server" Text='<%# Bind("Type") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="typeEdit" runat="server" Text='<%# Bind("Type") %>' Width="95%" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator5" ControlToValidate="typeEdit" ValidationGroup="EditValidation"
ValidationExpression="\w*" runat="server" ErrorMessage="Invalid Type" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" ValidationGroup="EditValidation" ControlToValidate="typeEdit"
runat="server" ErrorMessage="Type Required" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="typeAdd" runat="server" Width="95%" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" ControlToValidate="typeAdd"
ValidationGroup="AddValidation" ValidationExpression="\w*" runat="server" ErrorMessage="Invalid Type" />
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ProgNum" ReadOnly="true" HeaderText="ProgNum" ControlStyle-Width="95%" />
<asp:TemplateField HeaderText="AckDate">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Convert.ToDateTime(Eval("AckDate")).ToString("MM/dd/yyyy") %>' Width="95%"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Notes" >
<ItemTemplate>
<asp:Label ID="notes" runat="server" Text='<%# Bind("Notes") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="notesEdit" Text='<%# Bind("Notes") %>' runat="server" Width="95%"/>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="notesAdd" runat="server" Width="95
%" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ActivityDate">
<ItemTemplate>
<asp:Label ID="activityDate" runat="server" Text='<%#Convert.ToDateTime(Eval("activityDate")).ToString("MM/dd/yyyy") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="activityDateEdit" Text='<%#Convert.ToDateTime(Eval("activityDate")).ToString("MM/dd/yyyy") %>' runat="server" CssClass="date" Width="95%" />
<asp:CompareValidator ID="CompareValidator1" runat="server" Type="Date" Operator="DataTypeCheck" ValidationGroup="EditValidation"
ControlToValidate="activityDateEdit" ErrorMessage="Invalid Date" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" ValidationGroup="EditValidation" ControlToValidate="activityDateEdit"
runat="server" ErrorMessage="Date Required" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="activityDateAdd" runat="server" CssClass="date" Width="95%"/>
<asp:CompareValidator ID="CompareValidator2" runat="server" Type="Date" Operator="DataTypeCheck" ValidationGroup="AddValidation"
ControlToValidate="activityDateAdd" ErrorMessage="Invalid Date" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IsVoid">
<ItemTemplate>
<asp:CheckBox ID="isVoid" runat="server" Checked='<%# Eval("IsVoid") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="isVoidEdit" runat="server" Checked='<%# Eval("IsVoid") %>' Width="95%" />
</EditItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="isVoidAdd" runat="server" Width="95%" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="VoidReason">
<ItemTemplate>
<asp:Label ID="voidReason" runat="server" Text='<%# Bind("VoidReason") %>' Width="95%" />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="voidReasonEdit" runat="server" Width="95%" />
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="voidReasonAdd" runat="server" Width="95%" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" CausesValidation="false" CommandName="Edit"
Text="<img border=0 src=../Theme/Main/Images/edit.gif alt=Edit>" />
<asp:LinkButton ID="lbDelete" runat="server" CausesValidation="false" CommandName="Delete"
OnClientClick="if(!confirm('Do You Really want to Delete this Order Item?')) return false;"
Text="<img border=0 src=../Theme/Main/Images/delete.gif alt=Delete>" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lbAdd" runat="server" CausesValidation="true" CommandName="Update"
ValidationGroup="EditValidation" Text="<img border=0 src=../Theme/Main/Images/check.gif alt=Update>" />
<asp:LinkButton ID="lbDelete" runat="server" CausesValidation="false" CommandName="Cancel"
Text="<img border=0 src=../Theme/Main/Images/delete.gif alt=Cancel>" />
</EditItemTemplate>
<FooterStyle HorizontalAlign="Center" VerticalAlign="Top" />
<FooterTemplate>
<asp:LinkButton ID="lbAdd" runat="server" CausesValidation="false" CommandName="Add"
ValidationGroup="AddValidation" Text="<img border=0 src=../Theme/Main/Images/check.gif alt=Add>" />
<asp:LinkButton ID="lbDelete" runat="server" CausesValidation="false" CommandName="Cancel"
Text="<img border=0 src=../Theme/Main/Images/delete.gif alt=Cancel>" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<asp:TextBox ID="vendorEdit" runat="server" Text='<%# Bind("Vendor") %>' CssClass="InputTextBox"
Width="100px" />
</EmptyDataTemplate>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lbEdit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
In my project I am working on showing Task Group and Task (i.e. Parent-child) in one screen with the ability to Add/Edit/Delete the parent (Task Group) record and also to Add/Edit/Delete associated Task. For this I am using nested Grid View (parent-child).
I am implementing the sample application mentioned in the below link to my ASP.NET web based project.
http://www.codeproject.com/Articles/20047/Editable-Nested-GridView-All-in-One
my .ASPX looks as mentioned below:
<%# Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Unicorn.Master" CodeBehind="TaskAndTaskGroup.aspx.cs" Inherits="Vipassi.Web.TaskGroup.TaskAndTaskGroup"%>
<asp:Content ID="Content1" ContentPlaceHolderID="phContent" runat="server">
<script language="javascript" type="text/javascript">
function expandcollapse(obj, row) {
var div = document.getElementById(obj);
var img = document.getElementById('img' + obj);
if (div.style.display == "none") {
div.style.display = "block";
if (row == 'alt') {
img.src = "../../Resources/images/minus.gif";
}
else {
img.src = "../../Resources/images/minus.gif";
}
img.alt = "Close to view other TaskGroups";
}
else {
div.style.display = "none";
if (row == 'alt') {
img.src = "../../Resources/images/plus.gif";
}
else {
img.src = "../../Resources/images/plus.gif";
}
img.alt = "Expand to show Tasks";
}
}
</script>
<div>
<asp:GridView ID="GridView1" AllowPaging="True" BackColor="#f1f1f1"
AutoGenerateColumns="false" DataSourceID="ObjectDataSource1" DataKeyNames="task_group_id"
ShowFooter="true" Font-Size="Small"
Font-Names="Verdana" runat="server" GridLines="None" OnRowDataBound="GridView1_RowDataBound"
OnRowCommand="GridView1_RowCommand" OnRowUpdating="GridView1_RowUpdating" BorderStyle=Outset
OnRowDeleting="GridView1_RowDeleting" OnRowDeleted="GridView1_RowDeleted"
OnRowUpdated="GridView1_RowUpdated" AllowSorting="true">
<RowStyle BackColor="Gainsboro" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#0083C1" ForeColor="White" />
<FooterStyle BackColor="White" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="javascript:expandcollapse('div<%# Eval("task_group_id") %>', 'one');">
<img id="imgdiv<%# Eval("task_group_id") %>" alt="Click to show/hide Tasks for TaskGroup <%# Eval("task_group_id") %>" width="9px" border="0" src="../../Resources/images/plus.gif" />
</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TaskGroup ID" SortExpression="task_group_id">
<ItemTemplate>
<asp:Label ID="lblTaskGroupID" Text='<%# Eval("task_group_id") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblTaskGroupID" Text='<%# Eval("task_group_id") %>' runat="server"></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTaskGroupID" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Task Group" SortExpression="task_group">
<ItemTemplate><%# Eval("task_group") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtTaskGroup" Text='<%# Eval("task_group") %>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTaskGroup" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fiscal Year" SortExpression="Fiscal_Year">
<ItemTemplate><%# Eval("Fiscal_Year") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtFiscalYear" Text='<%# Eval("Fiscal_Year") %>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtFiscalYear" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Is Active" SortExpression="Active_Flag">
<ItemTemplate><%# Eval("Active_Flag")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtActiveFlag" Text='<%# Eval("Active_Flag") %>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtActiveFlag" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="linkDeleteTaskGroup" CommandName="Delete" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="linkAddTaskGroup" CommandName="AddTaskGroup" runat="server">Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="div<%# Eval("task_group_id") %>" style="display: none; position: relative; left: 15px; overflow: auto; width: 97%">
<asp:GridView ID="GridView2" AllowPaging="True" AllowSorting="true" BackColor="White" Width="100%" Font-Size="X-Small"
AutoGenerateColumns="false" Font-Names="Verdana" runat="server" DataKeyNames="task_group_id" ShowFooter="true"
OnPageIndexChanging="GridView2_PageIndexChanging" OnRowUpdating="GridView2_RowUpdating"
OnRowCommand="GridView2_RowCommand" OnRowEditing="GridView2_RowEditing" GridLines="None"
OnRowUpdated="GridView2_RowUpdated" OnRowCancelingEdit="GridView2_CancelingEdit" OnRowDataBound="GridView2_RowDataBound"
OnRowDeleting="GridView2_RowDeleting" OnRowDeleted="GridView2_RowDeleted" OnSorting="GridView2_Sorting"
BorderStyle="Double" BorderColor="#0083C1">
<RowStyle BackColor="Gainsboro" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#0083C1" ForeColor="White" />
<FooterStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Task ID" SortExpression="task_id">
<ItemTemplate>
<asp:Label ID="lblTaskID" Text='<%# Eval("task_id") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblTaskID" Text='<%# Eval("task_id") %>' runat="server"></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Task" SortExpression="task_name">
<ItemTemplate><%# Eval("task_name")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtTask" Text='<%# Eval("task_name")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTask" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fiscal Year" SortExpression="fiscal_year">
<ItemTemplate><%# Eval("fiscal_year")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtTaskFiscalYear" Text='<%# Eval("fiscal_year")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTaskFiscalYear" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Is Active" SortExpression="Active_Flag">
<ItemTemplate><%# Eval("Active_Flag")%></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtTaskActiveFlag" Text='<%# Eval("Active_Flag")%>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTaskActiveFlag" Text='' runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="linkDeleteTaskGroup" CommandName="Delete" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="linkAddTask" CommandName="AddTask" runat="server">Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource SortParameterName="sortExpression" EnablePaging="true" ID="ObjectDataSource1"
MaximumRowsParameterName="maxRecords" TypeName="Vipassi.BLL.Classes.TaskGroup.TaskGroupBLL"
SelectMethod="ListforTaskGroup" SelectCountMethod="ListCountforTaskGroup" StartRowIndexParameterName="startIndex"
runat="server">
<SelectParameters>
<asp:SessionParameter SessionField="orgId" Name="orgId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
Option 1:
You can disable the VIEWSTATE of ASPX page /User Control :
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="~/TaskAndTaskGroup.aspx.cs" Inherits="Vipassi.Web.TaskGroup.TaskAndTaskGroup" EnableViewState="false"%>
Option 2:
You can also change your source code to make sure the controls added during a post-back must match the type and position of the controls added during the initial request.
Hope this will help you.
I have a gridview control with paging. Everything is good in IE.
But in Firefox and Chrome, the design breaks because of paging.
I attach the screenshots from IE and Firefox here:
In IE:
In Firefox:
Here is my grid view:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderWidth="0"
AllowPaging="true" ShowFooter="true" PageSize="3" Width="100%" OnPageIndexChanging="GridView1_PageIndexChanging"
OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating"
OnRowDeleting="GridView1_RowDeleting" OnRowCommand="GridView1_RowCommand" HorizontalAlign="Center">
<AlternatingRowStyle CssClass="gridAlternateRow" />
<FooterStyle CssClass="gridFooter" />
<PagerSettings Mode="NumericFirstLast" />
<PagerStyle HorizontalAlign="Center" CssClass="GridPager" VerticalAlign="Middle" Wrap="False" />
<HeaderStyle CssClass="GridHeader" />
<RowStyle CssClass="gridRow" />
<Columns>
<asp:TemplateField HeaderText="ID" Visible="false">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%#Eval("ID") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lbladd" runat="server"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="From Date" HeaderStyle-Width="10%">
<ItemTemplate>
<asp:Label ID="lblFromDate" runat="server" Text='<%#Eval("FromDate") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox CssClass="myCalCss" ID="txtFromDate" runat="server" Text='<%#Eval("FromDate") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox CssClass="myCalCss" ID="txtAddFromDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqFromDate" ValidationGroup="ValgrpConUNIAnesthesiaFeeSchedule" ControlToValidate="txtAddFromDate" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
</FooterTemplate>
<HeaderStyle Width="15%"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="To Date" HeaderStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lblToDate" runat="server" Text='<%#Eval("ToDate") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox CssClass="myCalCss" ID="txtToDate" runat="server" Text='<%#Eval("ToDate") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox CssClass="myCalCss" ID="txtAddToDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqToDate" ValidationGroup="ValgrpConUNIAnesthesiaFeeSchedule" ControlToValidate="txtAddToDate" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
</FooterTemplate>
<HeaderStyle Width="15%"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Procedure Code" HeaderStyle-Width="15%">
<ItemTemplate>
<asp:Label ID="lblProcedureCode" runat="server" Text='<%#Eval("ProcedureCode") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtProcedureCode" runat="server" Text='<%#Eval("ProcedureCode") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtAddProcedureCode" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqProcedureCode" ValidationGroup="ValgrpConUNIAnesthesiaFeeSchedule" ControlToValidate="txtAddProcedureCode" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
</FooterTemplate>
<HeaderStyle Width="15%"></HeaderStyle>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="15%">
<ItemTemplate>
<span onclick="return confirm('Are you sure want to delete?')">
<asp:LinkButton CssClass="aDelete" ID="btnDelete" Text="Delete" runat="server" CommandName="Delete" />
</span>
<asp:LinkButton ID="btnEdit" Text="Edit" runat="server" CommandName="Edit" CssClass="aEdit" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" CssClass="aUpdate" />
<asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" CssClass="aSave" />
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="btnInsertRecord" runat="server" Text="Add" ValidationGroup="ValgrpConUNIAnesthesiaFeeSchedule" CommandName="Insert" />
</FooterTemplate>
<HeaderStyle Width="15%"></HeaderStyle>
</asp:TemplateField>
</Columns>
</asp:GridView>
I take a look at Firebug and this is what I got in both IE and Firefox. Same HTML.
What am I missing?
This has driven me crazy a few times in the past but I've always fudged it and moved on. Today I want to try and fix it!
I quite frequently create a GridView to display data and a FormView directly beneath in Insert mode with controls in the InsertItemTemplate corresponding to the columns in the GridView, so that it looks like the FormView is just an empty row of the GridView awaiting new data entry. This works great.
The problem is that I can never get the widths of the 'columns' (really just textboxes) in the FormView to correspond to the widths of the columns in the GridView above.
In the example below, as you can see, both the GridView and FormView have a width of 100% and, sure enough, when the page is rendered they're both exactly the same width (I gave the FormView a border briefly to check). However, even though the widths of the textboxes in the FormView are identical to the widths of the columns in the GridView, they don't display that way. The textboxes are slightly wider, and by the time you get to the right-most column the cumulative effect means that the alignment is way out.
I'm guessing the problem is something to do with border widths or some other hidden element which is being rendered, but I can't figure it out. I have to say, the amount by which the alignment is out seems more than the couple of pixels a border would affect things.
<asp:GridView ID="gvTPR" runat="server" DataSourceID="SQLTPR" AutoGenerateColumns="false" DataMember="DefaultView" DataKeyNames="TPRID" Width="100%" >
<RowStyle HorizontalAlign="Center" />
<EditRowStyle BackColor="#ccffff" />
<HeaderStyle BackColor="#013b82" ForeColor="White" />
<Columns>
<asp:BoundField DataField="TPREnteredAt" HeaderText="Entered At" ReadOnly="True" SortExpression="TPREnteredAt" ItemStyle-Width="24%" ControlStyle-Width="90%" />
<asp:BoundField DataField="TPRTemp" HeaderText="Temp" ReadOnly="True" SortExpression="TPRTemp" ItemStyle-Width="12%" ControlStyle-Width="90%"/>
<asp:BoundField DataField="TPRPulse" HeaderText="Pulse" ReadOnly="True" SortExpression="TPRPulse" ItemStyle-Width="12%" ControlStyle-Width="90%"/>
<asp:BoundField DataField="TPRRespiration" HeaderText="Respiration" ReadOnly="True" SortExpression="TPRRespiration" ItemStyle-Width="12%" ControlStyle-Width="90%"/>
<asp:BoundField DataField="TPRPCV" HeaderText="PCV" ItemStyle-Width="12%" ControlStyle-Width="90%"/>
<asp:BoundField DataField="TPRTP" HeaderText="TP" ItemStyle-Width="12%" ControlStyle-Width="90%" />
<asp:CommandField ButtonType="Button" InsertVisible="False" ShowEditButton="True" ItemStyle-Width="16%" UpdateText="Save" ControlStyle-Width="60px" />
</Columns>
<EmptyDataTemplate>
No TPR records exist
</EmptyDataTemplate>
</asp:GridView>
<asp:FormView ID="fvTPR" runat="server" DataSourceID="SQLTPR" DefaultMode="Insert" Width="100%" >
<InsertItemTemplate>
<asp:textbox ID="lblEnteredAt" runat="server" Text="Will be added automatically" Width="24%" />
<asp:TextBox ID="txtTemp" runat="server" Text='<%# Bind("TPRTemp")%>' Width="12%" />
<asp:TextBox ID="txtPulse" runat="server" Text='<%# Bind("TPRPulse")%>' Width="12%" />
<asp:TextBox ID="txtRespiration" runat="server" Text='<%# Bind("TPRRespiration")%>' Width="12%" />
<asp:TextBox ID="txtPCV" runat="server" Text='<%# Bind("TPRPCV")%>' Width="12%" />
<asp:TextBox ID="txtTP" runat="server" Text='<%# Bind("TPRTP")%>' Width="12%" />
<asp:Button ID="btnAddTPR" runat="server" Text="Save" Width="5%" />
</InsertItemTemplate>
</asp:FormView>
This renders like this:
How about using GridView footer for add funcionality? This way you will have all columns in same table and you'l get around your positioning problems.
Here is an example of how your gridview should look like:
<asp:GridView ID="gvTPR" runat="server" DataSourceID="SQLTPR" AutoGenerateColumns="False" ShowFooter="True" DataKeyNames="TPRID" Width="100%" EnableModelValidation="True">
<RowStyle HorizontalAlign="Center" />
<EditRowStyle BackColor="#ccffff" />
<HeaderStyle BackColor="#013b82" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="Entered At" SortExpression="TPREnteredAt">
<EditItemTemplate>
<asp:TextBox ID="lblEnteredAt" runat="server" Text='<%# Eval("TPREnteredAt") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("TPREnteredAt") %>'></asp:Label>
</ItemTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="24%" />
<FooterTemplate>
<asp:TextBox ID="lblEnteredAt" runat="server" Text="Will be added automatically" Width="24%" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Temp" SortExpression="TPRTemp">
<EditItemTemplate>
<asp:TextBox ID="txtTemp" runat="server" Text='<%# Eval("TPRTemp") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("TPRTemp") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTemp" runat="server" Text='<%# Bind("TPRTemp")%>' Width="12%" />
</FooterTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="12%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Pulse" SortExpression="TPRPulse">
<EditItemTemplate>
<asp:TextBox ID="txtPulse" runat="server" Text='<%# Eval("TPRPulse") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("TPRPulse") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPulse" runat="server" Text='<%# Bind("TPRPulse")%>' Width="12%" />
</FooterTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="12%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Respiration" SortExpression="TPRRespiration">
<EditItemTemplate>
<asp:TextBox ID="txtRespiration" runat="server" Text='<%# Eval("TPRRespiration") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("TPRRespiration") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtRespiration" runat="server" Text='<%# Bind("TPRRespiration")%>' Width="12%" />
</FooterTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="12%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="PCV">
<EditItemTemplate>
<asp:TextBox ID="txtPCV" runat="server" Text='<%# Bind("TPRPCV") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("TPRPCV") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPCV" runat="server" Text='<%# Bind("TPRPCV")%>' Width="12%" />
</FooterTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="12%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="TP">
<EditItemTemplate>
<asp:TextBox ID="txtTP" runat="server" Text='<%# Bind("TPRTP") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("TPRTP") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTP" runat="server" Text='<%# Bind("TPRTP")%>' Width="12%" />
</FooterTemplate>
<ControlStyle Width="90%" />
<ItemStyle Width="12%" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="lnkbtnEdit" runat="Server" Text="Edit" CommandName="Edit"
CausesValidation="false"></asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="lnkbtnUpdate" runat="Server" Text="Save" CommandName="Update"
CausesValidation="true"></asp:Button><br />
<asp:LinkButton ID="lnkbtnCancel" runat="Server" Text="Cancel" CommandName="Cancel"
CausesValidation="false"></asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="lnkbtnInsert" runat="Server" Text="Save" CommandName="Insert"
CausesValidation="true"></asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No TPR records exist
</EmptyDataTemplate>
</asp:GridView>
Hope this helps!
Regards,
Uros