Page containing multiple Gridview RowEditing Event not firing - asp.net

Web page is designed using .Net framework 4.5. Web pages contains 3 Grid views as follows:
Code for Gridview is as follows:
<asp:GridView ID="grdADetails" runat="server" AutoGenerateColumns="False" CssClass="tGrid" GridLines="Horizontal" ShowFooter="True" Width="100%" OnRowCancelingEdit="grdADetails_RowCancelingEdit" OnRowCommand="grdADetails_RowCommand" OnRowDataBound="grdADetails_RowDataBound" OnRowDeleting="grdADetails_RowDeleting" OnRowEditing="grdADetails_RowEditing" OnRowUpdating="grdADetails_RowUpdating">
<Columns>
<asp:TemplateField HeaderText="Mode Of Transport">
<EditItemTemplate>
<asp:DropDownList ID="DrpTMode" runat="server" CssClass="trvGridCmbBox" Width="90%">
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<table border="0" cellpadding="0" cellspacing="0" style="WIDTH: 100%">
<tr>
<td class="tGridTotal" style="Height : 25px;"></td>
</tr>
<tr>
<td class="GridEditArea" style="Height : 25px;">
<asp:DropDownList ID="DrpNTMode" runat="server" CssClass="trvGridCmbBox" Font-Size="8pt" Width="98%">
</asp:DropDownList>
</td>
</tr>
</table>
</FooterTemplate>
<HeaderTemplate>
<asp:Label ID="lblTMode" runat="server" Text="<%$ Resources:EResources, lblModeOfT %>" Width="100%"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblESubTypeCode" runat="server" Text='<%# Bind("ESubTypeCode") %>' Visible="False"></asp:Label>
<asp:Label ID="lblTMode" runat="server" Text='<%# Bind("TMode") %>'></asp:Label>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="12%" />
</asp:TemplateField>
//For Date part using Ajax Control
<asp:TemplateField HeaderText="Departure On">
<EditItemTemplate>
<asp:TextBox ID="txtDeptOn" runat="server" CssClass="trvGridTextBox" Text='<%# Bind("DeptOn") %>' Width="90%"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="ceDeptOn" runat="server" Format="MM/dd/yyyy" TargetControlID="txtDeptOn" Enabled="true" Animated="true" EnabledOnClient="true" EnableViewState="true" FirstDayOfWeek="Default"/>
</EditItemTemplate>
<FooterTemplate>
<table border="0" cellpadding="0" cellspacing="0" style="WIDTH: 100%">
<tr>
<td class="tGridTotal" style="Height : 25px;"></td>
</tr>
<tr>
<td class="GridEditArea" style="Height : 25px;">
<asp:TextBox ID="txtNewDeptOn" runat="server" CssClass="trvGridTextBox" Width="100%"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="ceNewDeptOn" runat="server" Enabled="true" Format="MM/dd/yyyy" TargetControlID="txtNewDeptOn" Animated="true" EnabledOnClient="true" EnableViewState="true" FirstDayOfWeek="Default"/>
</td>
</tr>
</table>
</FooterTemplate>
<HeaderTemplate>
<asp:Label ID="lblDepartureOn" runat="server" Text="<%$ Resources:EASEResources, lblDeparOn %>" Width="100%"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblDeptOn" runat="server" Text='<%# Bind("DeptOn") %>'></asp:Label>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
</asp:TemplateField>
//Same as above for remaining columns
//For Edit button column
<asp:TemplateField HeaderText="Edit">
<EditItemTemplate>
<asp:ImageButton ID="ImgUpdate" runat="server" CommandName="Update" ImageUrl="~/PL/images/save.png" />
<asp:ImageButton ID="ImageButton4" runat="server" CommandName="Cancel" ImageUrl="~/PL/images/remove1.png" />
</EditItemTemplate>
<FooterTemplate>
<table border="0" cellpadding="0" cellspacing="0" style="WIDTH: 100%">
<tr>
<td class="tGridTotal" style="height: 25px"></td>
</tr>
<tr>
<td class="GridEditArea" aria-orientation="vertical" style="height: 25px">
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="AddNew" CssClass="trvGridTextBox" ImageUrl="~/PL/images/save.png" />
</td>
</tr>
</table>
</FooterTemplate>
<HeaderTemplate>
<asp:Label ID="lblEdit" runat="server" Text="<%$ Resources:EResources, lblEdit %>" Width="100%"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CommandName="Edit" ImageUrl="~/PL/images/edit.png" />
</ItemTemplate>
<FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="4%" />
</asp:TemplateField>
Remaining two grid views are created in the similar format.
<asp:GridView ID="GrdTDetail" runat="server" AutoGenerateColumns="False" CssClass="travelGrid" GridLines="Horizontal" ShowFooter="True" Width="100%" OnRowCancelingEdit="GrdTDetail_RowCancelingEdit" OnRowCommand="GrdTDetail_RowCommand" OnRowDataBound="GrdTDetail_RowDataBound" OnRowDeleting="GrdTDetail_RowDeleting" OnRowEditing="GrdTDetail_RowEditing" OnRowUpdating="GrdTDetail_RowUpdating">
<Columns>
//Other Column Code
//Edit Column Code.
<asp:TemplateField HeaderText="Edit">
<EditItemTemplate>
<asp:ImageButton ID="ImageButton3" runat="server" CausesValidation="False" CommandName="Update" ImageUrl="~/PL/images/save.png" />
<asp:ImageButton ID="ImageButton4" runat="server" CausesValidation="False" CommandName="Cancel" ImageUrl="~/PL/images/remove1.png" />
</EditItemTemplate>
<FooterTemplate>
<table border="0" style="WIDTH: 100%">
<tr>
<td class="travelGridTotal" style="Height : 25px;"></td>
</tr>
<tr>
<td class="GridEditArea" style="Height : 25px;">
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="AddNewACC" CssClass="trvGridTextBox" ImageUrl="~/PL/images/save.png" />
</td>
</tr>
</table>
</FooterTemplate>
<HeaderTemplate>
<asp:Label ID="lblEdit" runat="server" Text="<%$ Resources:EResources, lblEdit %>" Width="100%"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/PL/images/edit.png" />
</ItemTemplate>
<FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="4%" />
</asp:TemplateField>
</Columns>
<FooterStyle CssClass="GridFooter" />
<HeaderStyle CssClass="travelGridhead" /
</asp:GridView>
//3rd Gridview code
<asp:GridView ID="GrdOtherExp" runat="server" AutoGenerateColumns="False" CellPadding="0" CssClass="travelGrid" GridLines="Horizontal" ShowFooter="True" Width="100%" OnRowCancelingEdit="GrdOtherExp_RowCancelingEdit" OnRowCommand="GrdOtherExp_RowCommand" OnRowDataBound="GrdOtherExp_RowDataBound" OnRowDeleting="GrdOtherExp_RowDeleting" OnRowEditing="GrdOtherExp_RowEditing" OnRowUpdating="GrdOtherExp_RowUpdating">
<Columns>
//Other Column Code
//Edit Column Code
<asp:TemplateField HeaderText="Edit">
<EditItemTemplate>
<asp:ImageButton ID="ImageButton3" runat="server" CausesValidation="False" CommandName="Update" ImageUrl="~/PL/images/save.png" />
<asp:ImageButton ID="ImageButton4" runat="server" CausesValidation="False" CommandName="Cancel" ImageUrl="~/PL/images/close.png" />
</EditItemTemplate>
<FooterTemplate>
<table border="0" cellpadding="0" cellspacing="0" style="WIDTH: 100%">
<tr>
<td class="travelGridTotal"></td>
</tr>
<tr>
<td class="GridEditArea"> <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="AddNewOExp" CssClass="trvGridTextBox" ImageUrl="~/PL/images/save.png" Height="16px" Width="16px" />
</td>
</tr>
</table>
</FooterTemplate>
<HeaderTemplate>
<asp:Label ID="lblEdit" runat="server" Text="<%$ Resources:EResources, lblEdit %>" Width="100%"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/PL/images/edit.png" />
</ItemTemplate>
<FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="2%" />
</asp:TemplateField>
</Columns>
<FooterStyle CssClass="GridFooter" />
<HeaderStyle CssClass="travelGridhead" /
</asp:GridView>
Each grid view has its own RowEditing, RowDataBound, RowUpdating, RowCancelEditing events. Gridview functionality is as follows:
User can enter data from footer row and using Save button having
command name as 'AddNew' saves the entered data to Item template in
row format. RowCommand event code is as follows:
protected void grdADetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
DataTable dtADetails = (DataTable)ViewState["dtAccDetails"];
ViewState["dtADetails"] = dtADetails;
if (e.CommandName.Equals("AddNew"))
{
//function to add data
//function to check required fields
}
}
User can edit and update the row data on RowEding event. Row edit button has command name as 'Edit'.
protected void grdADetails_RowEditing(object sender, GridViewEditEventArgs e)
{
grdADetails.EditIndex = e.NewEditIndex;
DataTable dtADetails = (DataTable)ViewState["dtADetails"];// cache data to session
//Code for editing the functionality.
}
User can save the edited row data or cancel the editing.
After publishing the pages to production server only one grid view events get fired, remaining two grid view events do not gets fired. Each editing button has command name as 'Edit' to fire edit event. Each

Related

trigger async callback from a radio button inside gridview

I have a gridview in which one of the column contains radio button. which i have placed inside item template. I want to trigger async callback to a panel in which i have a grid. this complete page is a user control.
When i am unable to add the trigger
<asp:GridView ID="grdBalStatus" runat="server" AutoGenerateColumns="false" Width="100%">
<HeaderStyle CssClass="dlresultheader" />
<RowStyle CssClass="griditems" />
<Columns>
<asp:BoundField DataField="TerminalId" HeaderStyle-Width="35%" />
<asp:BoundField DataField="Description"></asp:BoundField>
<asp:TemplateField HeaderStyle-Width="65%" HeaderText="Auto/Full Balancing Status">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="right" style="width: 32%">
<%--<asp:Label ID="lblSelAll" runat="server" CssClass="autoresultheader" Text="All:"></asp:Label>--%>
</td>
<td align="left" style="width: 60%">
<asp:RadioButton ID="rdAllAuto" runat="server" CssClass="autoresultheader" GroupName="AutoorFull1"
Text="Auto" ToolTip="Select auto balancing for all Self-Checkouts" />
<asp:RadioButton ID="rdAllFull" runat="server" CssClass="autoresultheader" GroupName="AutoorFull1"
Text="Full" ToolTip="Select full balancing for all Self-Checkouts" />
</td>
<td style="width: 8%">
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="right" style="width: 32%">
<asp:Label runat="server" ID="TermId" Text='<%# Eval("TerminalId") %>' CssClass="hide"></asp:Label>
</td>
<td align="left" style="width: 60%">
<asp:RadioButton ID="rdAuto" runat="server" CssClass="fullgriditems" GroupName="AutoorFull"
Text="Auto" />
<asp:RadioButton ID="rdFull" runat="server" CssClass="fullgriditems" GroupName="AutoorFull"
AutoPostBack="true" OnCheckedChanged="rdFull_CheckedChanged" Text="Full" />
</td>
<td style="width: 8%">
<%--<asp:Label runat="server" ID="Version" Text='<%# Eval("TerminalVersion") %>' CssClass="hide"></asp:Label> --%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TerminalVersion"></asp:BoundField>
</Columns>
</asp:GridView>
Code in the update panel
<asp:UpdatePanel ID="upFullBalTerm" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rdFull" EventName="CheckedChanged" />
</Triggers>
<ContentTemplate>
<table width="100%">
<tr id="trFullBalTl" class="hide" runat="server">
<td style="padding-top: 5px;" id="tdFullBalTerminal">
<asp:GridView runat="server" ID="grdFullBalTerminal" AutoGenerateColumns="false" Width="80%" BorderStyle="None" ShowHeader="true">
<HeaderStyle CssClass="dlresultheader" Width="15%" Height="30" />
<RowStyle CssClass="griditems" VerticalAlign="Bottom" />
<EmptyDataTemplate></EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="Terminal Id">
<HeaderStyle Width="12%" BorderStyle="None" />
<ItemStyle BorderStyle="none" CssClass="dlresultheader" />
<ItemTemplate>
<asp:Label runat="server" ID="lblFullBalTlId" Text='<%# Eval("terminal") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
Please suggest how to write the trigger.
I used a hidden button which is the trigger for the update panel. On click event of the radio button i called button click event using javascript.

Required Field Validators disappear in an update panel

I have an Update Panel which contains a GridView. 3 TextBoxes and a DropDownList control are Validated. I also have 3 different DDLs and 3 Checkbox controls in the panel that each trigger a rebind of the Gridview. When one of the un-validated DDLs or Checkboxes is changed they all fire the same changed event and I lose all of the Validation on the TextBoxes and the 1 DDL.
I'm a bit confused as to whether I should be setting Initial values on the validated or un-validated controls, if I should "group" the validation, and which set of controls needs to have the CausesValidation flag set. I hate to spam with massive amounts of code, but considering how much there is in this update panel....
<asp:UpdatePanel ID="UpdatePanel_Search" runat="server" >
<ContentTemplate>
<table class="auto-style2">
<tr>
<td>
<table class="auto-style1">
<tr>
<td class="auto-style3">
<div>
<table class="auto-style1" border="1px" frame="void">
<tr>
<td bgcolor="#00198D" style="text-align: center" class="auto-style19">
<asp:Label ID="FilterLabel3" runat="server" ForeColor="White" Text="Used by OEM"></asp:Label>
</td>
<td bgcolor="#00198D" style="text-align: center" class="auto-style9">
<asp:Label ID="FilterLabel4" runat="server" ForeColor="White" Text="Item Type"></asp:Label>
</td>
<td bgcolor="#00198D" style="text-align: center" class="auto-style24">
<asp:Label ID="FilterLabel5" runat="server" ForeColor="White" Text="Group Type"></asp:Label>
</td>
<td bgcolor="#00198D" style="text-align: center" class="auto-style12">
<asp:Label ID="FilterLabel6" runat="server" ForeColor="White" Text="Part Active"></asp:Label>
</td>
<td bgcolor="#00198D" style="text-align: center" class="auto-style17">
<asp:Label ID="FilterLabel7" runat="server" ForeColor="White" Text="Non-Inventory Part"></asp:Label>
</td>
<td bgcolor="#00198D" style="text-align: center" class="auto-style7">
<asp:Label ID="FilterLabel8" runat="server" ForeColor="White" Text="Part In Stock"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style19">
<asp:DropDownList ID="DDL_OEM" runat="server" Height="27px" Width="150px" AutoPostBack="True" AppendDataBoundItems="True" OnSelectedIndexChanged="Filter_DataSet" ></asp:DropDownList>
</td>
<td class="auto-style9">
<asp:DropDownList ID="DDL_ItemTypes" runat="server" Height="27px" Width="150px" AutoPostBack="True" AppendDataBoundItems="True" OnSelectedIndexChanged="Filter_DataSet" ></asp:DropDownList>
</td>
<td class="auto-style9">
<asp:DropDownList ID="DDL_GroupTypes" runat="server" Height="27px" Width="150px" AutoPostBack="True" AppendDataBoundItems="True" OnSelectedIndexChanged="Filter_DataSet" ></asp:DropDownList>
</td>
<td class="auto-style12">
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="Filter_DataSet" Checked="True" Style="text-align: center" />
</td>
<td class="auto-style17">
<asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True" OnCheckedChanged="Filter_DataSet" Style="text-align: center" />
</td>
<td class="auto-style7">
<asp:CheckBox ID="CheckBox3" runat="server" AutoPostBack="True" OnCheckedChanged="Filter_DataSet" Style="text-align: center" />
</td>
</tr>
</table>
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox_Ticket_Search"
ErrorMessage="Ticket Number is Required. Enter NOTICKET if the item you are requesting is for your tech stock(i.e. a tool, USB drive, etc.)"
ForeColor="Red">
</asp:RequiredFieldValidator>
</div>
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="TextBox_Part_Search"
ErrorMessage="Part Number is Required. Select a Part from the Catalog before submitting a request."
ForeColor="Red">
</asp:RequiredFieldValidator>
</div>
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="TextBox_Serial_Search"
ErrorMessage="System Serial Number is Required. Enter NOSERIAL if the item you are requesting is for your tech stock(i.e. a tool, USB drive, etc.)"
ForeColor="Red">
</asp:RequiredFieldValidator>
</div>
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server"
ControlToValidate="DDL_OEM_submit0"
ErrorMessage="System Model is a required field. Please select a Model from the Drop Down below."
InitialValue="0"
ForeColor="Red">
</asp:RequiredFieldValidator>
</div>
</td>
</tr>
<table class="auto-style1">
<tr>
<td class="auto-style34">
<table class="auto-style1">
<tr>
<td>
<asp:Label ID="Label_Comments_Search" runat="server" Text="Comments:"></asp:Label>
</td>
</tr>
<tr>
<td style="text-align: left">
<asp:TextBox runat="server"
ID="TextBox_Comments_Search"
TextMode="multiline"
TextWrapping="Wrap"
AcceptsReturn="True"
VerticalScrollBarVisibility="Visible" Height="100px" Width="300px">
</asp:TextBox>
</td>
</tr>
</table>
</td>
<td class="auto-style29">
<table class="auto-style1">
<tr>
<td class="auto-style4">
<asp:Label ID="Label_Ticket_Search" runat="server" Text="Ticket #:"></asp:Label>
</td>
<td class="auto-style32">
<asp:TextBox ID="TextBox_Ticket_Search" runat="server"></asp:TextBox>
<span class="auto-style23">*</span></td>
</td>
</tr>
<tr>
<td style="text-align: right">
<asp:Label ID="Label_Part_Search" runat="server" Text="Part #:"></asp:Label>
</td>
<td class="auto-style32">
<asp:TextBox ID="TextBox_Part_Search" runat="server" ReadOnly="true" BackColor="#CCCCCC"></asp:TextBox>
<span class="auto-style23">*</span>
</td>
</tr>
<tr>
<td style="text-align: right" class="auto-style21">
<asp:Label ID="Label12" runat="server" Text="Serial #:"></asp:Label></td>
<td class="auto-style32">
<asp:TextBox ID="TextBox_Serial_Search" runat="server"></asp:TextBox>
<span class="auto-style23">*</span></td>
</tr>
<tr>
<td style="text-align: right" class="auto-style21">
<asp:Label ID="Label_Damage_Search" runat="server" Text="Part Damaged:"></asp:Label>
</td>
<td style="text-align: left" class="auto-style31">
<asp:CheckBox ID="CheckBox_Damage_Search" runat="server"></asp:CheckBox>
</td>
</tr>
</table>
</td>
<td>
<table class="auto-style25">
<tr>
<td>
<table class="auto-style25">
<tr>
<td>
<asp:Label ID="Label15" runat="server" Style="text-align: left" Text="Model:"></asp:Label>
</td>
<td align="left">
<asp:DropDownList ID="DDL_OEM_submit0" runat="server">
</asp:DropDownList>
<span class="auto-style23">*</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button2" runat="server" Text="Submit Part Request" OnClick="Button2_Click" />
</td>
</tr>
</table>
</td>
<table class="auto-style1">
<tr>
<td>
<table class="auto-style1">
<tr>
<td class="auto-style8" valign="top">
<asp:GridView ID="GridView1"
runat="server"
AutoGenerateColumns="False"
DataKeyNames="ID"
DataSourceID="SqlDataSource1"
EnableModelValidation="True"
AllowSorting="True"
OnSelectedIndexChanged="Gridview1_SelectedIndexChanged"
AutoGenerateSelectButton="True"
BackColor="White"
BorderColor="#999999"
BorderStyle="None"
BorderWidth="1px"
CellPadding="3"
GridLines="Vertical" HorizontalAlign="Justify">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#00198D" ForeColor="White" />
<PagerStyle ForeColor="Black" BackColor="#999999" HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="#DCDCDC" />
<EmptyDataTemplate>
No records could be retrieved from the database. We apologize for the inconvenience.
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="OEMPartCode" HeaderText="OEMPartCode" SortExpression="OEMPartCode" />
<asp:BoundField DataField="OEM" HeaderText="OEM" InsertVisible="False" ReadOnly="True" SortExpression="OEM" />
<asp:BoundField DataField="Sub Categories" HeaderText="Models" InsertVisible="False" ReadOnly="True" SortExpression="Sub Categories" />
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="Red" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</td>
<td style="text-align: left" valign="top">
<asp:DetailsView
ID="DetailsView1"
runat="server"
DataSourceID="SqlDataSource2"
Height="50px"
Width="556px"
CellPadding="4"
AutoGenerateRows="False"
OnDataBound="DetailsView1_OnDataBound"
ForeColor="White"
EnableModelValidation="True"
DataKeyNames="ID"
HorizontalAlign="Left"
Style="margin-right: 0px">
<FieldHeaderStyle BackColor="#00198D" Font-Bold="True" ForeColor="White" />
<Fields>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="OEMPartCode" HeaderText="OEMPartCode" />
<asp:BoundField DataField="PartCode2" HeaderText="PartCode2" />
<asp:TemplateField HeaderText="UsedByOEM">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("UsedByOEM") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ItemType">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("JoinedItemType") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="GroupType">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("JoinedGroupType") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PartDesc" HeaderText="PartDescription" SortExpression="PartDesc" />
<asp:BoundField DataField="PartComment" HeaderText="PartComment" SortExpression="PartComment" />
<asp:BoundField DataField="PartCount" HeaderText="PartCount" SortExpression="PartCount" />
<asp:BoundField DataField="PartMin" HeaderText="PartMin" SortExpression="PartMin" />
<asp:CheckBoxField DataField="PartActive" HeaderText="PartActive" SortExpression="PartActive" />
<asp:BoundField DataField="MFRPartNumber" HeaderText="MFRPartNumber" SortExpression="MFRPartNumber" />
<asp:BoundField DataField="PartCapacity" HeaderText="PartCapacity" SortExpression="PartCapacity" />
<asp:CheckBoxField DataField="PreTurnRequired" HeaderText="PreTurnRequired" SortExpression="PreTurnRequired" />
<asp:TemplateField HeaderText="AssemblyPart">
<ItemTemplate>
<asp:Label ID="Label_AssemblyPart" runat="server" Text='<%# Bind("AssemblyPart") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Part Image">
<ItemTemplate>
<a href="javascript:void(window.open('<%# "ShowImage.aspx?PID="+ Eval("PartImage")%>','_blank','toolbar=no,menubar=no'))">
<asp:Image ID="FullImage" ToolTip="Click to download the full size image."
runat="server" ImageUrl='<%# "ShowThumb.aspx?size=120&PID="+ Eval("PartImage") %>' /></a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Part Image 2">
<ItemTemplate>
<a href="javascript:void(window.open('<%# "ShowImage.aspx?PID="+ Eval("PartImage2")%>','_blank','toolbar=no,menubar=no'))">
<asp:Image ID="Image1" ToolTip="Click to download the full size image."
runat="server" ImageUrl='<%# "ShowThumb.aspx?size=120&PID="+ Eval("PartImage2") %>' /></a>
</ItemTemplate>
</asp:TemplateField>
<asp:CheckBoxField DataField="NonInventoryPart" HeaderText="NonInventoryPart" SortExpression="NonInventoryPart" />
<asp:TemplateField HeaderText="Updated By">
<ItemTemplate>
<asp:Label ID="UserNameLabel" runat="server" Text='<%# Bind("CreatedByUser") %>' ReadOnly="True"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Modified">
<ItemTemplate>
<asp:Label ID="ModifiedDateLabel" runat="server" Text='<%# Bind("LastModifiedDate") %>' ReadOnly="True"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Fields>
<FooterStyle BackColor="#00198D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#00198D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" ForeColor="Black" Width="300px" />
</asp:DetailsView>
</td>
</tr>
</table>
</td>
</tr>
</table>
</table>
</td>
</tr>
</table>
</table>
</td>
</tr>
</table>
</table>
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
DataSourceMode="DataSet"
SelectCommand="SELECT Stuff">
<FilterParameters>
<asp:ControlParameter Name="UsedByOEM" ControlID="DDL_OEM" PropertyName="SelectedValue" />
<asp:ControlParameter Name="ItemType" ControlID="DDL_ItemTypes" PropertyName="SelectedValue" />
<asp:ControlParameter Name="GroupType" ControlID="DDL_GroupTypes" PropertyName="SelectedValue" />
</FilterParameters>
</asp:SqlDataSource>
<a></a>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConflictDetection="CompareAllValues"
SelectCommand="SELECT Stuff">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="ID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
Did you try giving the controls a group name?

How to make the Header static in Gridview scroll?

here I'm trying to make a scroll-able Grid View, which I did using the overflow, but the problem is, I want to make the Header section static, allowing only the content to be scrolled, here's my code:
<div class="BodyDiv" style="overflow: auto; height: 200px">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<table width="1024px">
<tr>
<td align="center">
<table width="980px">
<tr>
<td>
<asp:Panel ID="PanelDGV" runat="server" Height="250" ScrollBars="None" Width="515">
<asp:GridView ID="DGV" runat="server" AutoGenerateColumns="False" GridLines="None" AllowPaging="true" PageSize="50" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt">
<Columns>
<asp:BoundField DataField="ProjectCode" HeaderText="Project Code" />
<asp:BoundField DataField="ProjectName" HeaderText="Project Name" />
<asp:ButtonField ButtonType="Image" ImageUrl="../Support/Image/Edit.png" ItemStyle-HorizontalAlign="Center"
CommandName="CmdSearch" HeaderText="Edit">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:ButtonField>
</Columns>
<PagerStyle CssClass="pgr"></PagerStyle>
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
</asp:GridView>
</asp:Panel>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
is there anyway to do it? thank you.
<script src="../Scripts/ScrollableGridPlugin.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('#<%=Grd.ClientID %>').Scrollable();
}
)
You can download this js file from below url
http://code.google.com/p/dev-acuaman/source/browse/trunk/PyproduceEstad%C3%ACstica/EstadisticaProduce/Scripts/ScrollableGridPlugin.js?r=79
<asp:GridView ID="Grd" runat="server" Width="100%" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Country">
<ItemTemplate>
<asp:Label ID="lbl" runat="server" Text='<%# Eval("CountryName") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Enter Shipping Charge">
<ItemTemplate>
<asp:TextBox ID="txt" runat="server" Text='<%# Eval("charge") %>'></asp:TextBox>
<asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="txt"
ValidationGroup="txt" SetFocusOnError="true" Operator="DataTypeCheck" Type="Double"
ErrorMessage="Country Wise Shipping Charge must be number!">*</asp:CompareValidator>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="160px" VerticalAlign="Middle" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Enter No Of Days">
<ItemTemplate>
<asp:TextBox ID="txt1" runat="server" Text='<%# Eval("days") %>'></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="txt"
ValidationGroup="txt1" SetFocusOnError="true" Operator="DataTypeCheck" Type="Integer"
ErrorMessage="No Of Days must be number!">*</asp:CompareValidator>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="160px" VerticalAlign="Middle" />
</asp:TemplateField>
</Columns>
</asp:GridView>

asp .net Gridview height overflows into next div

I am having a Gridview inside a div tag
and there is a div below this div tasg containg other contents.
If I don't set the Gridview div height then the contents of GV overflows into parts present below the GV.
Else if I set, when the records are less, there would be a empty block after the GV. How do I solve this. Please have look at the code ...
<div style="height: 100%; width: 785px; margin-top: 0px; overflow: hidden; display: table;">
<tr>
<td>
<asp:GridView ID="dgAccessGrp" runat="server" Style="z-index: 101; left: 13px; position: absolute;
margin-top: 0px; width: 686px;" AutoGenerateColumns="False" DataKeyNames="access_group_id"
AllowPaging="True" RowStyle-Height="20px" CellPadding="3" CellSpacing="1" OnRowCancelingEdit="accessGrp_RowCancelingEdit"
OnRowDeleting="accessGrp_RowDeleting" OnRowEditing="accessGrp_RowEditing" OnRowUpdating="accessGrp_RowUpdating"
OnPageIndexChanging="dgAccessGrp_PageIndexChanging" OnRowCommand="dgAccessGrp_RowCommand"
OnRowDataBound="dgAccessGrp_RowDataBound" Font-Bold="False">
<Columns>
<asp:TemplateField HeaderText="SI No">
<ItemTemplate>
<asp:Label ID="lblAccessGrpID" runat="server" Width="70px" Text="<%# Bind('access_group_id') %>"
Visible="false"></asp:Label>
<asp:Label ID="lblSIno" runat="server" Width="15px" Text="<%#Container.DataItemIndex+1 %>"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Left" BackColor="#006699" Font-Names="arial,helvetica,sans-serif"
Font-Size="8pt" ForeColor="White" />
<ControlStyle Font-Names="Arial" Font-Size="8pt" />
</asp:TemplateField>
<asp:BoundField DataField="access_group_id" Visible="False" />
<asp:TemplateField HeaderText="Access group">
<ItemTemplate>
<asp:LinkButton ID="btnSelect" CommandArgument='<%# Bind("access_group_id") %>' CommandName='SelectAccessGroup'
Text='<%# Bind("access_group_name") %>' runat="server" Width="90px"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtAccessGrp" MaxLength="50" runat="server" Width="90px" Text='<%# Bind("access_group_name") %>'> </asp:TextBox>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Left" BackColor="#006699" Font-Names="arial,helvetica,sans-serif"
Font-Size="8pt" ForeColor="White" />
<ControlStyle Font-Names="Arial" Font-Size="8pt" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Business Unit">
<ItemTemplate>
<asp:Label ID="lblBU" runat="server" Width="70px" Text="<%# Bind('bu_name') %>"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblBU" runat="server" Width="70px" Text="<%# Bind('bu_id') %>" Visible="false"></asp:Label>
<asp:Label ID="lblIsActiveBU" runat="server" Width="70px" Text="<%# Bind('bu_active') %>"
Visible="false"></asp:Label>
<asp:DropDownList ID="dgDrpBU" runat="server" DataValueField="bu_id" DataTextField="bu_name">
</asp:DropDownList>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Left" BackColor="#006699" Font-Names="arial,helvetica,sans-serif"
Font-Size="8pt" ForeColor="White" />
<ControlStyle Font-Names="Arial" Font-Size="8pt" />
</asp:TemplateField>
<asp:TemplateField HeaderText="BU Line">
<ItemTemplate>
<asp:Label ID="lblBULine" runat="server" Width="70px" Text="<%# Bind('business_line_name') %>"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblBULine" runat="server" Width="70px" Text="<%# Bind('business_line_id') %>"
Visible="false"></asp:Label>
<asp:Label ID="lblIsActiveBULine" runat="server" Width="70px" Text="<%# Bind('business_line_active') %>"
Visible="false"></asp:Label>
<asp:DropDownList ID="dgDrpBULine" runat="server" DataValueField="business_line_id"
DataTextField="business_line_name">
</asp:DropDownList>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Left" BackColor="#006699" Font-Names="arial,helvetica,sans-serif"
Font-Size="8pt" ForeColor="White" />
<ControlStyle Font-Names="Arial" Font-Size="8pt" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Location">
<ItemTemplate>
<asp:Label ID="lblLocation" runat="server" Width="70px" Text="<%# Bind('location') %>"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblLocation" runat="server" Width="70px" Text="<%# Bind('location_id') %>"
Visible="false"></asp:Label>
<asp:Label ID="lblIsActiveStatus" runat="server" Width="70px" Text="<%# Bind('status') %>"
Visible="false"></asp:Label>
<asp:DropDownList ID="dgDrpBULocation" runat="server" DataValueField="location_id"
DataTextField="location">
</asp:DropDownList>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Left" BackColor="#006699" Font-Names="arial,helvetica,sans-serif"
Font-Size="8pt" ForeColor="White" />
<ControlStyle Font-Names="Arial" Font-Size="8pt" />
</asp:TemplateField>
<asp:CommandField ButtonType="Image" CancelImageUrl="~/IMAGEs/cross.gif" EditImageUrl="~/IMAGEs/edit.gif"
EditText="" HeaderText="" ShowEditButton="True" UpdateImageUrl="~/IMAGEs/check.gif"
UpdateText="">
<ControlStyle Font-Names="Arial" Font-Size="8pt" />
<HeaderStyle BackColor="#006699" Font-Names="Arial" Font-Size="8pt" ForeColor="White" />
<ItemStyle Width="30px" />
</asp:CommandField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:LinkButton ID="btnDelete" CommandArgument='<%# Bind("access_group_id") %>' OnClientClick="return confirm('Are you sure you want to delete this record?');"
runat="server" Width="60px" CommandName="Delete">Delete</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="50px" />
<HeaderStyle HorizontalAlign="Left" BackColor="#006699" Font-Names="arial,helvetica,sans-serif"
Font-Size="8pt" ForeColor="White" />
<ControlStyle Font-Names="Arial" Font-Size="8pt" />
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="Yellow" />
<PagerSettings Position="TopAndBottom" />
<PagerStyle Wrap="True" BackColor="#CCCCCC" HorizontalAlign="Center" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:pt7dataConnectionString %>"
SelectCommand="SELECT access_group_name, is_active, access_group_id, last_modified_by, date_stamp, bu_id, business_line_id, location_id FROM tbl_car_access_groups ORDER BY access_group_id DESC">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:pt7dataConnectionString %>"
SelectCommand="Select bu_id,bu_name from tbl_car_bu ORDER BY bu_name ASC"></asp:SqlDataSource>
</td>
</tr>
</div>
<div id="detailArea">
<br />
<asp:Label ID="lblError" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="9pt"
ForeColor="White" Visible="False" BackColor="#E2001A"></asp:Label>
<table style="height: 347px; width: 915px;">
<tr>
<td valign="top" bgcolor="#E1FFE1" style="border: 2px solid #808285">
<table>
<tr>
<td class="style26" style="font-family: Arial; color: #003b6a; font-size: 12px; font-weight: bold"
valign="bottom">
Select User(s) Below :
</td>
</tr>
<tr>
<td class="style17" valign="top">
<asp:ListBox ID="lbAllUsers" runat="server" Font-Names="Arial" Font-Size="9pt" Height="227px"
Width="432px" SelectionMode="Multiple"></asp:ListBox>
</td>
</tr>
<tr>
<td class="style27">
<asp:Button ID="btnAddToMemberList" runat="server" Text="Add Selected User(s) To 'Group Members' List"
BackColor="#215F8B" BorderColor="#A2BAD2" BorderStyle="Solid" Font-Bold="True"
Font-Names="Arial" Font-Size="9pt" ForeColor="White" Width="346px" Height="23px"
OnClick="btnAddToMemberList_Click" OnClientClick="return AddUserToList()" />
</td>
</tr>
<tr>
<td class="style27">
<asp:Button ID="btnAddToGAList" runat="server" Text="Add Selected User(s) To 'Group Administrators' List"
BackColor="#215F8B" BorderColor="#A2BAD2" BorderStyle="Solid" Font-Bold="True"
Font-Names="Arial" Font-Size="9pt" ForeColor="White" Width="346px" Height="23px"
OnClick="btnAddToGAList_Click" OnClientClick="return AddUserToList()" />
</td>
</tr>
<tr>
<td class="style27">
<asp:Button ID="btnAddToGDList" runat="server" Text="Add Selected User(s) To 'Delgated Responsibility' List"
BackColor="#215F8B" BorderColor="#A2BAD2" BorderStyle="Solid" Font-Bold="True"
Font-Names="Arial" Font-Size="9pt" ForeColor="White" Width="346px" Height="23px"
OnClick="btnAddToGDList_Click" OnClientClick="return AddUserToList()" />
</td>
</tr>
</table>
</td>
<td valign="top" bgcolor="#FFEFB0" style="border: 2px solid #808285" class="style31">
<table>
<tr>
<td class="style28" style="font-family: Arial; color: #003b6a; font-size: 12px; font-weight: bold"
valign="bottom">
Group Members :
</td>
</tr>
<tr>
<td class="style29" valign="top">
<asp:ListBox ID="lbMembers" runat="server" Font-Names="Arial" Font-Size="9pt" Height="227px"
Width="432px" SelectionMode="Multiple"></asp:ListBox>
</td>
</tr>
<tr>
<td class="style30">
<asp:Button ID="btnDelMember" runat="server" Text="Remove Selected Member(s)" BackColor="#215F8B"
BorderColor="#A2BAD2" BorderStyle="Solid" Font-Bold="True" Font-Names="Arial"
Font-Size="9pt" ForeColor="White" Width="212px" Height="23px" OnClick="btnDelMember_Click"
OnClientClick="return DelMembers()" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<table style="border: 2px solid #808285; width: 913px; background-color: #FFEFB0;">
<tr>
<td>
<table>
<tr>
<td style="font-family: Arial; color: #003b6a; font-size: 12px; font-weight: bold"
valign="bottom">
Group Administrators :
</td>
<td style="font-family: Arial; color: #003b6a; font-size: 12px; font-weight: bold"
valign="bottom">
Delegated Responsibility To :
</td>
</tr>
<tr>
<td>
<asp:ListBox ID="lbGAs" runat="server" Font-Names="Arial" Font-Size="9pt" Height="227px"
Width="432px" SelectionMode="Multiple"></asp:ListBox>
</td>
<td>
<asp:ListBox ID="lbGDs" runat="server" Font-Names="Arial" Font-Size="9pt" Height="227px"
Width="432px" SelectionMode="Multiple"></asp:ListBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnDelGA" runat="server" Text="Remove Selected User(s)" BackColor="#215F8B"
BorderColor="#A2BAD2" BorderStyle="Solid" Font-Bold="True" Font-Names="Arial"
Font-Size="9pt" ForeColor="White" Width="212px" Height="23px" OnClick="btnDelGA_Click"
OnClientClick="return DelGAs()" />
</td>
<td>
<asp:Button ID="btnDelGD" runat="server" Text="Remove Selected User(s)" BackColor="#215F8B"
BorderColor="#A2BAD2" BorderStyle="Solid" Font-Bold="True" Font-Names="Arial"
Font-Size="9pt" ForeColor="White" Width="212px" Height="23px" OnClick="btnDelGD_Click"
OnClientClick="return DelGDs()" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td style="font-family: Arial; color: #003b6a; font-size: 12px; font-weight: bold">
Name/Email Pairs - Can be pasted into Outlook : (Press Ctrl+A within box to
select all) <asp:TextBox ID="tbUserNames" runat="server" Height="140px" TextMode="MultiLine"
Width="881px" ReadOnly="True"></asp:TextBox>
<br />
<br />
<br />
</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
</div>
Set the minimum height of the div containing your gridview.
Also set the overflow property to auto of the gridview div
You can refer these links
Mysterious min-height behavior
CSS Max Height Property
Problem in Style you have added to gridview
Please remove "position: absolute" attribute from your style.

ASP.NET How to recreate the following HTML in a Gridview

Hey I am trying to recreate the following HTML
<table border="0" cellspacing="0" cellpadding="2" width="100%" id="productListTable">
<tr>
<th rowspan="2">Product Name</th>
<th rowspan="2" >Pack Size</th>
<th rowspan="2" >Trade Price</th>
<th colspan="2" style="border:none;">Discount</th>
<th rowspan="2" >Actual Price</th>
<th rowspan="2">Stock</th>
<th rowspan="2">Quantity</th>
</tr>
<tr class="sub">
<th >PLC</th>
<th >Total</th>
</tr>
In my Gridview the first tr is no problem as this can just be standard header text in my columns but I am wondering how I can add this sub tr
<tr class="sub">
<th >PLC</th>
<th >Total</th>
</tr>
And also how to add this style, to my existing column
<th colspan="2" style="border:none;">Discount</th>
Heres my gridview at the moment
<asp:GridView ID="productListTable" runat="server" DataSourceID="srcProductListPerCustomer" AutoGenerateColumns="False" AlternatingRowStyle-CssClass="tr_dark" HeaderStyle-CssClass="header_req" BorderWidth="0px" GridLines="None" AllowPaging="true" PageSize="25" EmptyDataText="No records." AllowSorting="false" Width="100%" DataKeyNames="product_ID_key" OnRowDataBound="productListTable_RowDataBound" OnRowCommand="productListTable_RowCommand" >
<Columns>
<asp:TemplateField HeaderText="Product Name" HeaderStyle-Width="250px" SortExpression="productName" ItemStyle-CssClass="product_name" >
<ItemTemplate>
<asp:Label ID="ProductNameField" runat="server" Text='<%# Eval("productName").ToString() %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField HeaderText="Pack Size" HeaderStyle-Width="70px" SortExpression="packSize">
<ItemTemplate>
<asp:Label ID="PackSizeField" runat="server" Text='<%# Eval("packSize").ToString()%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField HeaderText="Trade Price" HeaderStyle-Width="130px" SortExpression="address">
<ItemTemplate>
<asp:Label ID="TradePriceField" runat="server" Text='<%# DisplayMoney(Eval("tradePrice").ToString())%>'></asp:Label>
<asp:Label ID="TradePriceFieldHidden" runat="server" Text='<%# Eval("tradePrice").ToString()%>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField HeaderText="Discount" HeaderStyle-Width="60px" SortExpression="discount">
<ItemTemplate>
<asp:Label ID="DiscountField" runat="server" Text='<%# Eval("discount").ToString() + "%" %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField HeaderText="Actual Price" HeaderStyle-Width="130px" SortExpression="actualPrice">
<ItemTemplate>
<asp:Label ID="ActualPriceField" runat="server" Text='<%# DisplayMoney(Eval("actualPrice").ToString())%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField HeaderText="Stock" HeaderStyle-Width="130px" SortExpression="stock_indicator">
<ItemTemplate>
<asp:Label ID="StockField" runat="server" Text='<%# DisplayStockLevel(Eval("stock_indicator").ToString()) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtQuantity" Columns="5"></asp:TextBox><br />
<asp:LinkButton runat="server" ID="btnRemove" Text="Remove" CommandName="Remove" CommandArgument='<%# Eval("product_ID_key") %>' style="font-size:12px;" Visible="false"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle CssClass="header_req" />
<AlternatingRowStyle CssClass="tr_dark" />
<PagerStyle CssClass="pagination" />
<PagerSettings PageButtonCount="3" FirstPageText="First" LastPageText="Last" NextPageText="Next" PreviousPageText="Previous" Mode="NumericFirstLast" />
</asp:GridView>
I'm not sure about your current scenario, but it seems like you might want to take a look at the ListView control.
Out of the box GridView tends to create a ton of extra HTML to get it to look right. I'm not sure you'll ever be able to get exactly what you're looking for that way.
I did see that you have some paging stuff in there; if you go the ListView route, you'll want to use a DataPager as well.
I would use a ListView instead. It's a little more flexible, and you can just spit out table rows through the item template. It won't be the prettiest HTML ever, but if you're looking to use one of the provided ASP.NET controls for the job, that's probably the most forgiving.
I think you can get away with something like this:
<table cellpadding="3" cellspacing="0">
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<tr>
<td>Test</td>
<td>Test again</td>
</tr>
</ItemTemplate>
</asp:DataList>
</table>

Resources