I have a gridview in my APSX that looks like below:
I want to be able to stretch the 'Comments' data cells so they stretch to the bottom of each section (stretch an extra 3 cells down)
I have tried numerous things and nothing seems to be working for me, I was wondering if anyone could point me in the right direction to do this.
This is the code I am using for my Gridview..
...
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20%" HeaderText="Project Name">
<ItemTemplate>
<asp:Label ID="ProjectNameLab" runat="server" Text='<%# Bind("[Project Name]")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20%" HeaderText="Customer Name" SortExpression="Customer Name">
<ItemTemplate>
<asp:Label ID="CustomerNameLab" runat="server" Text='<%# Bind("[Customer Name]")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="10%" HeaderText="Month" SortExpression="Month">
<ItemTemplate>
<asp:Label ID="MonthLab" runat="server" Text='<%# Bind("Month")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="10%" HeaderText="App Date" SortExpression="ApplicationDate">
<ItemTemplate>
<asp:Label ID="ApplicationDateLab" runat="server" Text='<%# Bind("ApplicationDate")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="12%" HeaderText="Value" SortExpression="ThisApp">
<ItemTemplate>
<asp:LinkButton ID="ThisAppLab" runat="server" Text='<%# Bind("ThisApp")%>'></asp:LinkButton>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
Enabled="True" PopupControlID="EditPopup1" TargetControlID="ThisAppLab"
BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20%" HeaderText="Comments" SortExpression="Comments">
<ItemTemplate>
<asp:Label ID="CommentsLab" runat="server" Text='<%# Bind("Comments")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="true">
<ItemTemplate>
<tr>
<td colspan="5">
<td>
<asp:Label Style="padding: 0px 0px 0px 0px" Width="100%" ID="PaidLbl" runat="server" Text='<%# Bind("Paid")%>'></asp:Label>
<itemstyle width="100%" />
</td>
</td>
</tr>
<tr>
<td colspan="5"></td>
<td>
<asp:Label Style="padding: 0px 0px 0px 0px" Width="100%" ID="DifferenceLbl" runat="server"></asp:Label>
<itemstyle width="100%" />
</td>
</tr>
<tr>
<td colspan="5"></td>
<td>
<asp:Label Style="padding: 0px 0px 0px 0px" Width="100%" ID="DateFP" runat="server" Text='<%# Bind("Date")%>'></asp:Label>
<itemstyle width="100%" />
</td>
</tr>
<tr>
<td colspan="5"></td>
<td>
<asp:Label Style="padding: 0px 0px 0px 0px; visibility: hidden" Width="100%" ID="BlankRowLbl" Text="Blank" runat="server"></asp:Label>
<itemstyle width="100%" />
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Any help or advice would be appreciated, Thank you in advance.
Within your template field you should add a table and set the row span to the amount of rows that you want. Something like :
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20%" HeaderText="Comments" SortExpression="Comments">
<ItemTemplate>
<table>
<tr>
<td rowspan="3">
<asp:Label ID="CommentsLab" runat="server" Text='<%# Bind("Comments")%>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
EDIT: Try putting the cell in the other template field as another column instead of its own template field.
Related
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
i have a grid view in which i need to divide a cell into 2 equal rows...
here i can divide but i cannot divide into equal parts....
how can i make a cell exactly into 2 rows....
here is my code..
UPDATED ONE
<Wizard:WizardGridView ID="gvresmgt" runat="server" AllowPaging="False" AllowSorting="True"
AutoGenerateColumns="false" WizardCustomPager="False" EnableModelValidation="True" CssClass="style1" ShowHeader="False" >
<Columns>
<asp:TemplateField >
<ItemStyle Width="100px" HorizontalAlign="left" />
<ItemTemplate>
<asp:Label runat="server" ID="lblTitle" Text='<%# Eval("BGP_ID")%>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField >
<ItemStyle Width="100px" HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label runat="server" ID="lblDescription" Text='<%# Eval("BGP_DESC")%>' > </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle Width="100px" HorizontalAlign="Center" />
<ItemTemplate>
**<div id="1" style="border-bottom: solid 1px #C0C0C0">
<asp:Label runat="server" ID="lblPlanStart" Font-Bold="true" Text="Projects"></asp:Label>
<br/>
<br/>
</div>
<asp:Label runat="server" ID="Label3" Font-Bold="true" Text="SubTotal"></asp:Label> **
</ItemTemplate>
</asp:TemplateField>
</Columns>
</Wizard:WizardGridView>
Try with the height set to half
<ItemStyle Width="100px" Height="20px" HorizontalAlign="Center" />
<ItemTemplate>
<table style="border: 1px solid black;">
<tr>
<td style="border: 1px solid black;">
<asp:Label runat="server" ID="lblPlanStart" Font-Bold="true" Text="Unknown"></asp:Label>
</td>
</tr>
<tr>
<td style="border: 1px solid black;">
<asp:Label runat="server" ID="lblPlanStart" Font-Bold="true" Text="Projects"></asp:Label>
</td>
</tr>
<tr>
<td style="border: 1px solid black;">
<asp:Label runat="server" ID="Label3" Font-Bold="true" Text="SubTotal"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
i want to generate a dynamic id of my datepicker. below jquery function shows the datetimepicker as the id is defined as static.
$(function () {
var dates = $("#ContentPlaceHolder1_gvdLCStatus_txtInvoiceDate_0").datepicker(
{
dateFormat: 'dd/mm/yy',
defaultDate: '+1w',
changeMonth: false,
numberOfMonths: 1,
showOn: 'both',
buttonImage: 'Images/calendar_month.png',
buttonImageOnly: true,
onSelect: function (selectedDate) {
var option = this.id == "ContentPlaceHolder1_gvdLCStatus_txtInvoiceDate_0" ? "minDate" : "maxDate",
instance = $(this).data("datepicker");
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings);
dates.not(this).datepicker("option", option, date);
}
});
});
I want to generate a dynamic ID for the DatePicker. and How that ive tried various time but couldnt find the actual way of doing.Thanks.
<asp:GridView ID="gvdLCStatus" runat="server" DataKeyNames="LCID" AutoGenerateColumns="false"
AllowPaging="True" PageSize="4" EmptyDataText="No Record Found" CssClass="mGrid"
OnPageIndexChanging="gvdLCStatus_PageIndexChanging" OnRowCommand="gvdLCStatus_RowCommand"
OnSelectedIndexChanged="gvdLCStatus_SelectedIndexChanged" OnRowDataBound="gvdLCStatus_RowDataBound"
OnRowCreated="gvdLCStatus_RowCreated">
<AlternatingRowStyle CssClass="test" />
<Columns>
<asp:TemplateField HeaderText="LC Number">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("LCID") %>' Visible="false"></asp:Label>
<a href="#" onclick="linkbtnTest('<%# "#"+Eval("LCNumber") %>')">
<%# Eval("LCNumber") %></a>
<%-- <div id='<%# Eval("ShipmentID") %>' style="display: none;">
</div>--%>
<div id='<%# Eval("LCNumber") %>' style="display: none;">
<asp:GridView ID="gvShipmentStatus" runat="server" AutoGenerateColumns="false" DataKeyNames="ShipmentID"
OnRowCommand="gvShipmentStatus_RowCommand" OnRowDataBound="gvShipmentStatus_RowDataBound"
CssClass="mGrid">
<Columns>
<asp:BoundField DataField="InvoiceNumber" HeaderText="Invoice Number" />
<asp:BoundField DataField="InvoiceDate" HeaderText="Invoice Date" />
<asp:BoundField DataField="BLNumber" HeaderText="B/L Number" />
<asp:BoundField DataField="BLDate" HeaderText="B/L Date" />
<asp:BoundField DataField="VesselName" HeaderText="Vessel Name" />
<asp:BoundField DataField="VoyageNumber" HeaderText="Voyage Number" />
<asp:BoundField DataField="DueDate" HeaderText="Due Date" />
<asp:BoundField DataField="ContractedShipmentSchedule" HeaderText="Shipment Schedule" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:ImageButton ID="ImgShipmentDelete" runat="server" ImageUrl='<%# isDelete_img(Session["isAdmin"].ToString()) %>'
Enabled='<%# isDelete(Session["isAdmin"].ToString()) %>' CommandName="DeleteShipmentRecord"
CommandArgument='<%# Eval("ShipmentID") %>' AlternateText="DeleteShipmentRecord"
OnClientClick="return confirm_delete();" Style='<%# delete_style(Session["isAdmin"].ToString()) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<%-- <asp:ImageButton ID="ImgShipmentEdit" runat="server" ImageUrl="~/Images/edit.png"
CommandName="EditShipmentRecord" ImageAlign="Middle" CommandArgument='<%# Eval("ShipmentID") %>'
AlternateText="EditShipmentRecord" OnClientClick='linkbtnTest(<%# Eval("ShipmentID) %>)' />
--%>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="EditShipmentRecord"
CommandArgument='<%# Eval("ShipmentID")+":"+Eval("LCStatusID")%>'>
<%--<asp:Label ID="Label2" runat="server" Text='<%# Eval("ShipmentID") %>' Visible="true"></asp:Label>--%> <img src="Images/edit.png" alt="Edit" />
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<%--</div>--%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ContractNumber" HeaderText="Contract Number" />
<asp:BoundField DataField="Amount" HeaderText="Amount" />
<asp:BoundField DataField="Qty" HeaderText="Quantity" />
<asp:TemplateField>
<ItemTemplate>
Add Shipment Status
<div id='<%# Eval("LCID") %>' style="display: none;">
<table>
<tr>
<td class="td_records" style="padding-top: 5px;">
Invoice Number
</td>
<td class="td_records" style="padding-top: 5px;">
Invoice Date (dd/mm/yyyy)
</td>
<td class="td_records" style="padding-top: 5px;">
B/L Number
</td>
<td class="td_records" style="padding-top: 5px;">
B/L Date (dd/mm/yyyy)
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtInvoiceNumber" runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtInvoiceDate" runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtBLNumber" runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtBLDate" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="td_records" style="padding-top: 5px;">
VesselName
</td>
<td class="td_records" style="padding-top: 5px;">
VoyageNumber
</td>
<td class="td_records" style="padding-top: 5px;">
DueDate (dd/mm/yyyy)
</td>
<td class="td_records" style="padding-top: 5px;">
ShipmntSchedule (dd/mm/yyyy)
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtVesselName" runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtVoyageNumber" runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtDueDate" runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtShipmntSchedule" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top: 10px;">
<asp:Button ID="btnSubmitShipment" runat="server" Text="Submit" CommandName="Select"
OnCommand="btnSubmitShipment_Command" CssClass="btnSubmitCSS" />
<asp:Button ID="btnResetShipmentRecord" runat="server" Text="Reset" CssClass="btnSubmitCSS" />
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="imgDelete" runat="server" ImageUrl='<%# isDelete_img(Session["isAdmin"].ToString()) %>'
Enabled='<%# isDelete(Session["isAdmin"].ToString()) %>' CommandName="DeleteRecord"
CommandArgument='<%# Eval("LCID") %>' AlternateText="DeleteRecord" OnClientClick="return confirm_delete();"
Style='<%# delete_style(Session["isAdmin"].ToString()) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="imgEdit" runat="server" ImageUrl="~/Images/edit.png" CommandName="EditRecord"
CommandArgument='<%# Eval("LCID") %>' AlternateText="EditRecord" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="pgr" />
</asp:GridView>
As an option you may use such selector:
var dates = $("[id*='txtInvoiceDate']", "#<%= gvdLCStatus.ClientID %>")
But better consider to set CssClass property on textboxes and use class selector
Why do you select by id? Why don't you go with class name? $('.datebox').dateTimepicker(...
i found an alternate of validating it with asp.net required field validators. No other option was there and had to maintain the time constraint.
Thanks Guys.
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>
<asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="opendiarysource" Font-Size="Small" style="font-size: 8pt; border-top-style: solid; border-right-style: solid; border-left-style: solid; border-bottom-style: solid; color: black;" AllowSorting="True" >
<Columns>
<asp:TemplateField HeaderText="Date Added" SortExpression="added7">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("added7") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<br />
<asp:Label ID="Label1" runat="server" Text='<%# Bind("added7") %>'></asp:Label><br />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ByWhom" HeaderText="Added By" SortExpression="ByWhom" />
<asp:BoundField DataField="BOOKNO" HeaderText="Book #" SortExpression="BOOKNO" />
<asp:BoundField DataField="ClearedBy" HeaderText="Cleared By" SortExpression="ClearedBy" Visible="False" />
<asp:BoundField DataField="Done7" HeaderText="Date Done" SortExpression="Done7" Visible="False" />
<asp:BoundField DataField="ForWhom" HeaderText="For Whom" SortExpression="ForWhom" />
I want this last field to show up as a row underneath instead of a column.
<asp:TemplateField HeaderText="Note" SortExpression="Text">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Text") %>'></asp:TextBox>
</EditItemTemplate
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Text") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Try to use ListView instead of GridView, if that would be an option for you. That has lot of templating features.
The Templates would like:
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("col1") %>' ></asp:Label>
</td>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("col2") %>' ></asp:Label>
</td>
</tr>
<tr>
<td colspan="10">
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Text") %>' ></asp:Label>
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("col1") %>' ></asp:Label>
</td>
<td>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("col2") %>' ></asp:Label>
</td>
</tr>
<tr>
<td colspan="10">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Text") %>' ></asp:TextBox>
</td>
</tr>
</EditItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
Convert all the rows to columns by this way....
public DataTable ConvertColumnsAsRows(DataTable dt)
{
DataTable dtnew = new DataTable();
for (int i = 0; i <= dt.Rows.Count; i++)
{
dtnew.Columns.Add(Convert.ToString(i));
}
DataRow dr;
for (int j = 0; j < dt.Columns.Count; j++)
{
dr = dtnew.NewRow();
dr[0] = dt.Columns[j].ToString();
for (int k = 1; k <= dt.Rows.Count; k++)
dr[k] = dt.Rows[k - 1][j];
dtnew.Rows.Add(dr);
}
return dtnew;
}
This function is used to convert columns to rows