select all checkboxes using one checkbox in datalist - asp.net

this is my code when i click on checkbox chkall , all checkboxes should be activated.
so can please anyone help me
<asp:DataList ID="DataList1" runat="server" OnItemCommand="DataList1_ItemCommand" CellPadding="4" ForeColor="#333333">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderTemplate>
<asp:CheckBox ID="chkall" runat="server" onclick="checktrue()" />
EMPID ENAME DESIGNATION DOJ SALARY DEPTNO Edit/Update
</HeaderTemplate>
<ItemStyle BackColor="#EFF3FB" />
<ItemTemplate>
<asp:CheckBox ID="chkone" runat="server" />
<asp:Label ID="lblempid" runat="server" Text='<%#Eval("empid") %>' />
<%#Eval("ename") %>
<%#Eval("desg") %>
<%#Eval("doj") %>
<%#Eval("salary") %>
<%#Eval("deptno") %>
<asp:Button ID="btnedit" runat="server" Text="EDIT" CommandName="Edit" />
</ItemTemplate>
<AlternatingItemStyle BackColor="White" />
<EditItemTemplate>
<asp:Label ID="lblempid" runat="server" Text='<%#Eval("empid") %>' />
<asp:TextBox ID="txtename" runat="server" Text='<%#Eval("ename") %>' />
<asp:TextBox ID="txtdesg" runat="server" Text='<%#Eval("desg") %>' />
<asp:TextBox ID="txtdoj" runat="server" Text='<%#Eval("doj") %>' />
<asp:TextBox ID="txtsalary" runat="server" Text='<%#Eval("salary") %>' />
<asp:TextBox ID="txtdeptno" runat="server" Text='<%#Eval("deptno") %>' />
<asp:Button ID="btnupdate" runat="server" Text="Update" CommandName="Update" />
<asp:Button ID="btncancel" runat="server" Text="Cancel" CommandName="Cancel" />
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="btmdelete" runat="server" OnClick="btndelete_Click" Text="Delete" />
<asp:TextBox ID="txtempid" runat="server" Width="60"></asp:TextBox>
<asp:TextBox ID="txtename" runat="server" Width="60"></asp:TextBox>
<asp:TextBox ID="txtdesg" runat="server" Width="60"></asp:TextBox>
<asp:TextBox ID="txtdoj" runat="server" Width="60"></asp:TextBox>
<asp:TextBox ID="txtsalary" runat="server" Width="60"></asp:TextBox>
<asp:TextBox ID="txtdeptno" runat="server" Width="60"></asp:TextBox>
<asp:Button ID="btnadd" runat="server" Text="add" CommandArgument="add" />
</FooterTemplate>
<SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:DataList>

I recommend doing it on the client side. Here is an example with jquery
function checkAll(){
$("#DataList1 :checkbox").prop("checked", $("#chkall").prop("checked"));
}

Related

How to loop through controls within a gridview and store their values in an array?

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.

Error Handling for empty textboxes in aspnet and vbnet

I have an ADD button in my FormView in ASP.NET. And I have txtName on it that should first check if the textbox is empty. If it was empty, the ADD button should message Please fill up the form.
I tried the traditional error handling in vb.net like
If txtbox.text = "" then
error msg
end if
but it is not applicable when making a web page using ASP.NET backend: VBNET.
<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID" DataSourceID="SqlDataSource1" Height="92px" Width="835px" AllowPaging="True" CellPadding="3" DefaultMode="Insert" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" GridLines="Horizontal" BackImageUrl= "howto.jpg" style="margin-bottom: 12px">
<EditRowStyle BackColor="#738A9C" BorderStyle="Solid" Font-Bold="True" ForeColor="#F7F7F7" />
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<InsertItemTemplate>
<asp:Label ID="lblName" runat="server" Text="Name of Applicant" Font-Size ="10pt" Font-Names="Arial" ></asp:Label>
<asp:Label ID="lblBday" runat="server" Font-Names="Arial" Font-Size="10pt" Text="Birthday"></asp:Label>
<asp:Label ID="Gender" runat="server" Font-Names="Arial" Font-Size="10pt" Text="Gender"></asp:Label>
<br />
<asp:TextBox ID="txtName" runat="server" Height="19px" Text='<%# Bind("Name") %>' Width="216px" Font-Size ="10" Font-Names="Arial"></asp:TextBox>
<asp:TextBox ID="txtBday" runat="server" Font-Names="Arial" Font-Size="10pt" Height="19px" Text='<%# Bind("Birthday") %>' TextMode="Date" Width="216px"></asp:TextBox>
<asp:DropDownList ID="txtGender" runat="server" Height="19px" Width="222px" SelectedValue='<%# Bind("Gender") %>'>
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:Label ID="lblAddress" runat="server" Font-Names="Arial" Font-Size="10pt" Text="Address"></asp:Label>
<asp:Label ID="lblContact" runat="server" Font-Names="Arial" Font-Size="10pt" Text="Contact"></asp:Label>
<br />
<asp:TextBox ID="txtAddress" runat="server" Font-Names="Arial" Font-Size="10pt" Height="19px" Text='<%# Bind("Address") %>' Width="488px"></asp:TextBox>
<asp:TextBox ID="txtContact" runat="server" Font-Names="Arial" Font-Size="10pt" Height="19px" Text='<%# Bind("Contact") %>' Width="216px"></asp:TextBox>
<br />
<br />
<br />
<asp:Label ID="lblEduc" runat="server" Font-Names="Arial" Font-Size="10pt" Text="Educational Attainment"></asp:Label>
<asp:Label ID="lblCourse" runat="server" Font-Names="Arial" Font-Size="10pt" Text="Course"></asp:Label>
<br />
<asp:DropDownList ID="txtEduc" runat="server" Height="19px" SelectedValue='<%# Bind("Education") %>' Width="495px">
<asp:ListItem>High School</asp:ListItem>
<asp:ListItem>College Diploma (2-3 years)</asp:ListItem>
<asp:ListItem>College Undergrad (4-5 years)</asp:ListItem>
<asp:ListItem>Bachelor's Degree</asp:ListItem>
<asp:ListItem Value="Master">Masteral</asp:ListItem>
<asp:ListItem>Doctor</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="txtCourse" runat="server" Font-Names="Arial" Font-Size="10pt" Height="19px" Text='<%# Bind("Course") %>' Width="216px"></asp:TextBox>
<br />
<br />
<br />
<asp:Button ID="btnAdd" runat="server" Text="ADD" Font-Bold="True" Font-Size="Medium" ForeColor="Black" BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" CausesValidation="True" ValidationGroup="Insert" Font-Names="Berlin Sans FB Demi" CommandName="Insert" />
<asp:Button ID="btnCancel" runat="server" Text="CANCEL" Font-Bold="True" Font-Names="Berlin Sans FB Demi" Font-Size="Medium" ForeColor="Black" BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" CommandName="Cancel" />
</InsertItemTemplate>
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
</asp:FormView>
You can't show that alert on a webapp, but you can use javascript in order to do it.
In code behind declare this function:
Public Sub AlertMessage(ByVal mensaje As String, ByVal pag As Page)
pag.ClientScript.RegisterStartupScript(Me.GetType(), "showConfirm", "Alerta('" & mensaje & "');", True)
End Sub
Then call it from your ADD button like this:
If txtbox.text = "" then
AlertMessage(msg, Me.Page)
end if
Hope this helps
I've learn from some research that there is other way for error handling using ASPNET. I used the validation control and validation group.
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup ="FillUp" runat="server" ControlToValidate ="txtName" ErrorMessage="Please Enter Your Name"></asp:RequiredFieldValidator><br />
<asp:Button ID="btnAdd" runat="server" Text="ADD" Font-Bold="True" Font-Size="Medium" ForeColor="Black" BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" CausesValidation="True" ValidationGroup="FillUp" Font-Names="Berlin Sans FB Demi" CommandName="Insert" />
enter image description here
I also add this code in my Web.config
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
I know, what you are thinking,"This guy has a poor desig", lol, well the important is you know the code xD

RequiredFieldValidator is not Valid even if there is values

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>

Getting information from parent GridView to a nested GridView

I'm hoping someone can help me get data from a GridView into another GridView I made inside it. I'm trying to get the wo_id field from the first GridView into the second GridView's datasource (created inside the first).
Right now, in the code below, I have "tasks = tasks" in the WHERE clause of the "partsused" SqlDataSource, and I want it to use the wo_id field from the parent GridView instead (thus showing the correct list of parts for the specific work order).
<%# Page Language="VB" MaintainScrollPositionOnPostback="true" MasterPageFile="~/Main.master"
AutoEventWireup="false" CodeFile="WorkOrders.aspx.vb" Inherits="PendingWO" Title="Standard Work Orders" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<center>
<h3>
Standard Work Orders</h3>
<asp:LinkButton ID="lbPrintVersion" runat="server">View Printable Version</asp:LinkButton><br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="wo_id"
DataSourceID="workOrders" BackColor="White" BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" CellPadding="3" GridLines="Vertical" EmptyDataText="No records"
PageSize="5">
<Columns>
<asp:ButtonField Text="Button" Visible="False" />
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField SortExpression="wo_id" HeaderText="Work Order">
<ItemTemplate>
<asp:Label ID="lblWONum" runat="server" Text='<%# Eval("wo_id") %>' Font-Size="X-Large" /><br />
<asp:ImageButton ID="btnHours" runat="server" ImageUrl="~/App_Themes/Images/hoursClock.png"
Height="40px" Width="40px" ToolTip="Hours" CommandName="Hours" />
<asp:ImageButton ID="btnParts" runat="server" Height="40px" ImageUrl="~/App_Themes/Images/parts.png"
Width="40px" ToolTip="Parts Used" CommandName="Parts" />
<asp:HiddenField ID="hfColor" runat="server" Value='<%# Eval("machine_status_color") %>' />
</ItemTemplate>
<EditItemTemplate>
session("workorderid") = '<%# Eval("wo_id") %>'
<asp:Label ID="lblWONum" runat="server" Text='<%# Eval("wo_id") %>' Font-Size="X-Large" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:GridView ID="GridView1" runat="server" DataSourceID="partsUsed" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" DataKeyNames="parts_used_id">
<Columns>
<asp:ButtonField Text="Button" Visible="False" />
<asp:BoundField DataField="parts_used_id" HeaderText="parts_used_id" InsertVisible="False"
ReadOnly="True" SortExpression="parts_used_id" Visible="False" />
<asp:BoundField DataField="tasks" HeaderText="Work Order" ReadOnly="True"
SortExpression="tasks" />
<asp:TemplateField HeaderText="Part" SortExpression="Part">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="partsList" DataTextField="Part"
DataValueField="part_id" SelectedValue='<%# Bind("part_id") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Part") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="part_id" HeaderText="part_id" SortExpression="part_id"
Visible="False" />
<asp:BoundField DataField="quantity" HeaderText="Quantity" SortExpression="quantity" />
<asp:BoundField DataField="cost" DataFormatString="{0:C}" HeaderText="Price Per" SortExpression="cost" />
<asp:BoundField DataField="full_name" HeaderText="Entered By"
SortExpression="full_name" ReadOnly="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<EmptyDataTemplate>
No Parts Logged<br />
</EmptyDataTemplate>
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="250px" />
<EditItemTemplate>
<asp:HiddenField ID="hfWOId" runat="server" Value='<%# Eval("wo_id") %>' />
<asp:HiddenField ID="hfDept" runat="server"
Value='<%# Eval("machine_type_id") %>' Visible = "false" />
<asp:HiddenField ID="hfMachine" runat="server"
Value='<%# Eval("machine_id") %>' />
<asp:HiddenField ID="hfReason" runat="server"
Value='<%# Eval("reason_id") %>' />
<asp:SqlDataSource ID="sqlDepartments" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [type_description], [machine_type_id] FROM [list_machine_types] ORDER BY [type_description]">
</asp:SqlDataSource>
<asp:DropDownList ID="ddlDepartment" runat="server" DataSourceID="sqlDepartments" Visible = "false"
DataTextField="type_description" DataValueField="machine_type_id" SelectedValue='<%# Bind("machine_type_id") %>'
AutoPostBack="True"
onselectedindexchanged="ddlDepartment_SelectedIndexChanged">
</asp:DropDownList>
<br />
<asp:Label ID="Label30" runat="server" Font-Bold="true" Text="Machine Number:" Visible = "false"></asp:Label>
<asp:DropDownList ID="ddlMachine" runat="server" Visible = "false">
</asp:DropDownList>
<br />
<asp:Label ID="Label10" runat="server" Font-Bold="true" Text="Serial Number:" Visible = "false"></asp:Label><asp:Label
ID="lblSerialNum" runat="server" Text='<% #Eval("serial_number") %>' Visible = "false"></asp:Label><asp:Label
ID="Label50" runat="server" Font-Bold="true" Text="Machine Status:" Visible = "false"></asp:Label>
<asp:DropDownList ID="ddlMachineStatus" runat="server" DataSourceID="machineStatus" Visible = "false"
DataTextField="machine_status_desc" DataValueField="machine_status_id" SelectedValue='<%# Bind("machine_status_id") %>'>
</asp:DropDownList>
<br />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Department:"></asp:Label>
<asp:Label ID="lblReason" runat="server" Text='<%# Eval("reason_desc") %>'></asp:Label> <br />
<asp:Label ID="Label29" runat="server" Text="Issued To:" Font-Bold="true"></asp:Label>&nbsp
<asp:Label ID="lblIssuedTo" runat="server" Text='<% #Eval("issue_to_desc") %>'></asp:Label><br />
<asp:Label ID="Label39" runat="server" Text="Description:" Font-Bold="true"></asp:Label><br />
<asp:Label ID="lblDescription" runat="server" Text='<% #Eval("work_order_desc") %>'></asp:Label><br />
<asp:Label ID="lblMaterialLabel" runat="server" Text="Material:" Font-Bold="true" Visible="false"></asp:Label>&nbsp
<asp:Label ID="lblMaterial" runat="server" Text='<% #Eval("material_nbr_MATNR") %>' Visible="false"></asp:Label><br />
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="250px" Wrap="True" />
<EditItemTemplate>
<asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Department:"></asp:Label>
<asp:DropDownList
ID="ddlReason" runat="server">
</asp:DropDownList>
<asp:Label ID="Label29" runat="server" Font-Bold="true" Text="Issued To:"></asp:Label>
<asp:DropDownList ID="ddlIssuedTo" runat="server" DataSourceID="issuedTo" DataTextField="issue_to_desc"
DataValueField="issued_to" SelectedValue='<%# Bind("issued_to") %>'>
</asp:DropDownList>
<br />
<asp:Label ID="Label39" runat="server" Font-Bold="true" Text="Description:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Height="54px" Text='<%# Bind("work_order_desc") %>'
Width="273px" TextMode="MultiLine"></asp:TextBox><br />
<asp:Label ID="lblMaterialLabel" runat="server" Text="Material:" Font-Bold="true" Visible="false"></asp:Label>&nbsp
<asp:DropDownList ID="ddlMaterial" runat="server" AppendDataBoundItems="True" Visible="false"
DataSourceID="sqlMaterials" DataTextField="material_nbr_MATNR"
DataValueField="material_nbr_MATNR"
SelectedValue='<%# Bind("material_nbr_MATNR") %>'>
<asp:ListItem Enabled="true" Text="None" Value="None" />
</asp:DropDownList>
<br />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label28" runat="server" Text="Requested By:" Font-Bold="true"></asp:Label>&nbsp
<asp:Label ID="lblRequestedBy" runat="server" Text='<% #Eval("requested_by") %>'></asp:Label><br />
<asp:Label ID="Label48" runat="server" Text="Requested On:" Font-Bold="true"></asp:Label>&nbsp
<asp:Label ID="lblRequestedOn" runat="server" Text='<% #Eval("requested_on", "{0:d}") %>'></asp:Label><br />
<asp:Label ID="Label78" runat="server" Text="Required By:" Font-Bold="true"></asp:Label>&nbsp
<asp:Label ID="lblRequiredBy" runat="server" Text='<% #Eval("required_by", "{0:d}") %>'></asp:Label>
<br />
<asp:Label ID="Label77" runat="server" Text="WO Status:" Font-Bold="true"></asp:Label>
<asp:LinkButton ID="lbWOStatus" runat="server" Text='<% #Eval("status_description") %>'
CommandName="ChangeWOStatus"></asp:LinkButton>
<asp:DropDownList ID="ddlWOStatus" Visible="False" runat="server" AutoPostBack="True"
DataSourceID="woStatus" DataTextField="status_description" DataValueField="status_id"
OnSelectedIndexChanged="updateWOStatus" SelectedValue='<%# Bind("wo_status_id") %>'>
</asp:DropDownList>
<asp:LinkButton ID="lbCancel" runat="server" CommandName="CancelStatusChange" Visible="False">Cancel</asp:LinkButton><br />
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="250px" />
<EditItemTemplate>
<asp:Label ID="Label28" runat="server" Font-Bold="true" Text="Requested By:"></asp:Label>
<asp:Label ID="lblRequestedBy" runat="server" Text='<% #Eval("requested_by") %>'></asp:Label><br />
<asp:Label ID="Label48" runat="server" Font-Bold="true" Text="Requested On:"></asp:Label>
<asp:Label ID="lblRequestedOn" runat="server" Text='<% #Eval("requested_on", "{0:d}") %>'></asp:Label><br />
<asp:Label ID="Label78" runat="server" Font-Bold="true" Text="Required By:"></asp:Label>
<asp:TextBox ID="txtRequiredBy" runat="server" Text='<%# Bind("required_by") %>'
Width="100px"></asp:TextBox><br />
<asp:Label ID="Label77" runat="server" Font-Bold="true" Text="WO Status:"></asp:Label>
<asp:Label ID="lblWOStatus" runat="server" Text='<%# Eval("status_description") %>'></asp:Label>
<br />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" Enabled="True" SelectedDate='<%# Eval("required_by") %>'
TargetControlID="txtRequiredBy">
</asp:CalendarExtender>
<asp:LinkButton ID="lbWOStatus" runat="server" CommandName="ChangeWOStatus" Text='<% #Eval("status_description") %>'
Visible="False"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnApprove" runat="server" Text="Approve" BackColor="#00C000" Font-Size="Medium"
Height="40px" Width="70px" CommandName="Approve" />
<br />
<asp:Button ID="btnDeny" runat="server" Text="Deny" BackColor="#C00000" Font-Size="Medium"
ForeColor="Black" Height="40px" Width="70px" CommandName="Deny" />
<br />
<asp:Label ID="lblPending" runat="server" Text="Pending Approval" Visible="False"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hfPriority" runat="server" Value='<%# Eval("priority", "{0:N}") %>' />
<asp:HiddenField ID="hfApprovalStatus" runat="server" Value='<% #Eval("approval_status_id") %>' />
<asp:ImageButton ID="btnTopPriority" runat="server" CommandName="MakeTopPriority"
ImageUrl="~/App_Themes/Images/priority.png" /><br />
<asp:ImageButton ID="btnUp" runat="server" Height="40px" ImageUrl="~/App_Themes/Images/upArrow.png"
Width="40px" CommandName="Up" /><br />
<asp:ImageButton ID="btnDown" runat="server" Height="40px" ImageUrl="~/App_Themes/Images/downArrow.png"
Width="40px" CommandName="Down" /><br />
<asp:LinkButton ID="lbChangePriority" runat="server" CommandArgument='<%# Eval("wo_id") %>'
CommandName="ChangePriority">Notify New Priority</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbDelete" runat="server" CommandArgument='<%# Eval("wo_id") %>'
CommandName="DeleteWO">Delete</asp:LinkButton>
<br />
<br />
<asp:LinkButton ID="lbMoveToProjects" runat="server" CommandArgument='<%# Eval("wo_id") %>'
CommandName="MoveToProjects" OnClientClick="javascript:return confirm('Are you sure you want to move this to projects?')" Visible="false">Move To Projects</asp:LinkButton>
<br />
<br />
<asp:LinkButton ID="lbEngineeringChange" runat="server" CommandArgument='<%# Eval("wo_id") %>' CommandName="EngineeringChange" Visible="false">Push For Engineering Change</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbPrintISO" runat="server" CommandName="PrintISO">Print ISO</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No work orders.<br />
</EmptyDataTemplate>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
</center>
<br />'
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<center>
<asp:SqlDataSource ID="workOrders" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="sp_WorkOrders"
UpdateCommand="UPDATE fact_work_orders SET machine_id = #machine_id, reason_id = #reason_id, machine_status_id = #machine_status_id, issued_to = #issued_to, work_order_desc = #work_order_desc, material_nbr_MATNR = #material_nbr_MATNR, required_by = #required_by WHERE wo_id = #wo_id"
SelectCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="machine_id" />
<asp:Parameter Name="reason_id" />
<asp:Parameter Name="machine_status_id" />
<asp:Parameter Name="issued_to" />
<asp:Parameter Name="work_order_desc" />
<asp:Parameter Name="material_nbr_MATNR" />
<asp:Parameter Name="required_by" />
<asp:Parameter Name="wo_id" Type="Int16" />
</UpdateParameters>
<SelectParameters>
<asp:QueryStringParameter Name="issuedTo" QueryStringField="issuedTo" DefaultValue="0" />
<asp:QueryStringParameter Name="woStatus" QueryStringField="woStatus" Type="String"
DefaultValue="%" />
<asp:SessionParameter DefaultValue="0" Name="level" SessionField="level" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="woStatus" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [status_description], [status_id] FROM [list_wo_status] WHERE ([status_id] <> #status_id)">
<SelectParameters>
<asp:Parameter DefaultValue="3" Name="status_id" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="machineStatus" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [machine_status_desc], [machine_status_id] FROM [list_machine_status]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="departments" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [type_description], [machine_type_id] FROM [list_machine_types]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="issuedTo" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [issued_to], [issue_to_desc] FROM [list_issued_to]"></asp:SqlDataSource>
<asp:SqlDataSource ID="sqlMaterials" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [material_nbr_MATNR] FROM [vdim_materials] ORDER BY [material_nbr_MATNR]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="partsUsed" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [fact_parts_used] WHERE [parts_used_id] = #parts_used_id"
InsertCommand="INSERT INTO [fact_parts_used] ([wo_id], [part_id], [quantity]) VALUES (#wo_id, #part_id, #quantity)"
SelectCommand="SELECT * FROM
(SELECT parts_used_id, dim_users.[user_name], full_name,
wo_id as tasks,
fact_parts_used.part_id, dim_parts.part_number+' '+dim_parts.part_desc as Part, quantity, cost
FROM fact_parts_used
INNER JOIN dim_users ON dim_users.[user_id] = fact_parts_used.[user_id]
INNER JOIN dim_parts ON dim_parts.part_id = fact_parts_used.part_id
) a
WHERE tasks is not null AND tasks = tasks "
UpdateCommand="UPDATE [fact_parts_used] SET [part_id] = #part_id, [quantity] = #quantity, cost = #cost WHERE [parts_used_id] = #parts_used_id"
>
<SelectParameters>
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="parts_used_id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="part_id" Type="Int32" />
<asp:Parameter Name="quantity" Type="Int32" />
<asp:Parameter Name="parts_used_id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="wo_id" Type="Int32" />
<asp:Parameter Name="part_id" Type="Int32" />
<asp:Parameter Name="quantity" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
</center>
</asp:Content>

ASP.NET Web application performs slow in client PC

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.

Resources