Compilation Error after deoplyment. Doesn't recognize 'Theme' attribute - asp.net

My local copy works fine, then I publish the website and I get this error.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'Theme' is not a member of 'ASP.invoice_aspx'.
Source Error:
Line 1: <%# page title="Invoice" language="VB" masterpagefile="~/MasterPage.master" autoeventwireup="false" inherits="Invoice, App_Web_1d5eb-af" theme="Default" %>
Line 2:
Line 3: <asp:Content ID="Content1" ContentPlaceHolderID="Head" Runat="Server">
Source File: C:\Inetpub\eSolutions_xyAMP_DEV\Invoice.aspx Line: 1
What is going on here?
HTML SOURCE
<%# Page Title="Invoice" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Invoice.aspx.vb" Inherits="Invoice" Theme="Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width:100%;">
<tr>
<td align="center">
<asp:panel id="pnl" runat="server"
Width="992px" Wrap="False" HorizontalAlign="Center" >
<asp:Button id="btnPrepareInvoice" runat="server" Text="Trial Invoice" ></asp:Button>
<asp:Button id="btnFinalize" runat="server" Text="Final Invoice" ></asp:Button>
</asp:panel>
</td>
</tr>
</table>
<br />
<table width="100%">
<tr>
<td class="Subhdr" align="center" >
<asp:Label ID="Label7" Cssclass="ScreenHdr" runat="server" Font-Bold="True"
Font-Size="Medium" Height="24px"
Width="221px">Issued Contracts</asp:Label>
</td>
</tr>
</table>
<asp:datagrid id="dgrContracts"
runat="server" HorizontalAlign="Center" BorderColor="#C0C0FF"
ForeColor="Blue" Font-Size="8pt" Font-Bold="True" BorderWidth="1px"
BorderStyle="Solid" Font-Names="Arial"
ShowFooter="True" OnPageIndexChanged="IssueDataGrid_Page"
OnSortCommand="IssueDataGrid_Sort" AllowPaging="True" CellPadding="2"
GridLines="Horizontal" AutoGenerateColumns="False"
AllowSorting="True" OnItemCommand="IssueDataGrid_Command" Width="100%">
<FooterStyle Wrap="False" HorizontalAlign="Left" VerticalAlign="Top"></FooterStyle>
<SelectedItemStyle Wrap="False" BackColor="#E0E0E0"></SelectedItemStyle>
<EditItemStyle Wrap="False"></EditItemStyle>
<AlternatingItemStyle Font-Size="8pt" Font-Bold="True" Wrap="False" HorizontalAlign="Left" Height="18px"
BorderWidth="1px" ForeColor="#0000C0" BorderStyle="Solid" BorderColor="#C0C0FF" VerticalAlign="Middle"
></AlternatingItemStyle>
<ItemStyle Font-Size="8pt" Font-Names="Arial" Font-Bold="True" Wrap="False" HorizontalAlign="Left"
Height="18px" ForeColor="#0000C0" VerticalAlign="Middle"></ItemStyle>
<HeaderStyle Font-Size="8pt" Font-Names="Arial" Font-Bold="True" Wrap="False" HorizontalAlign="Left"
Height="18px" ForeColor="White" BackColor="Blue"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button id="btnSelect" runat="server" Width="13px" BackColor="Yellow" ForeColor="White"
Height="13px" CommandName="Select"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="MBI_Selected"></asp:BoundColumn>
<asp:BoundColumn DataField="CUST_CombinedNumber" SortExpression="CUST_CombinedNumber" HeaderText="Number">
<HeaderStyle Width="60px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="CUST_Name" SortExpression="CUST_Name" HeaderText="Name" HeaderStyle-Width="110px" />
<asp:BoundColumn DataField="DisplayDate" SortExpression="MBI_Date" HeaderText="Effective">
<HeaderStyle Width="80px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="VEHL_Year" HeaderText="Year">
<HeaderStyle Width="30px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="DisplayMake" HeaderText="Make">
<HeaderStyle Width="100px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="VEHL_Model" HeaderText="Model">
<HeaderStyle Width="120px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="MBI_PlanCode" HeaderText="Plan">
<HeaderStyle Width="30px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="DisplayExchangePrice" HeaderText="Exch">
<HeaderStyle Width="30px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="MBI_DlrCost" HeaderText="Cost" DataFormatString="{0:C}">
<HeaderStyle Width="30px"></HeaderStyle>
</asp:BoundColumn>
</Columns>
<PagerStyle VerticalAlign="Top" NextPageText=">>>>" Height="18px" PrevPageText="<<<<"
HorizontalAlign="Left" ForeColor="White" BackColor="Blue" Wrap="False"></PagerStyle>
</asp:datagrid>
<table width="100%">
<tr>
<td class="Subhdr" align="center" >
<asp:Label ID="Label1" Cssclass="ScreenHdr" runat="server" Font-Bold="True"
Font-Size="Medium" Height="24px"
Width="221px">Cancelled Contracts</asp:Label>
</td>
</tr>
</table>
<asp:datagrid id="dgrCancels"
runat="server" HorizontalAlign="Center" BorderColor="#C0C0FF"
ForeColor="Blue" Font-Size="8pt" Font-Bold="True" BorderWidth="1px"
BorderStyle="Solid" Font-Names="Arial" PageSize="5" ShowFooter="True" OnPageIndexChanged="CancelDataGrid_Page"
OnSortCommand="CancelDataGrid_Sort" AllowPaging="True" CellPadding="2"
GridLines="Horizontal" AutoGenerateColumns="False" AllowSorting="True"
OnItemCommand="CancelDataGrid_Command" Width="100%">
<FooterStyle Wrap="False" HorizontalAlign="Left" VerticalAlign="Top"></FooterStyle>
<SelectedItemStyle Wrap="False" BackColor="#E0E0E0"></SelectedItemStyle>
<EditItemStyle Wrap="False"></EditItemStyle>
<AlternatingItemStyle Font-Size="8pt" Font-Bold="True" Wrap="False" HorizontalAlign="Left" Height="18px"
BorderWidth="1px" ForeColor="#0000C0" BorderStyle="Solid" BorderColor="#C0C0FF" VerticalAlign="Middle"
></AlternatingItemStyle>
<ItemStyle Font-Size="8pt" Font-Names="Arial" Font-Bold="True" Wrap="False" HorizontalAlign="Left"
Height="18px" ForeColor="#0000C0" VerticalAlign="Middle"></ItemStyle>
<HeaderStyle Font-Size="8pt" Font-Names="Arial" Font-Bold="True" Wrap="False" HorizontalAlign="Left"
Height="18px" ForeColor="White" BackColor="Blue"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button id="btnCancelSelect" runat="server" Width="13px" BackColor="Yellow" ForeColor="White"
Height="13px" CommandName="Select"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn Visible="False" DataField="CNCL_ID">
<HeaderStyle Width="0px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="CNCL_Selected"></asp:BoundColumn>
<asp:BoundColumn DataField="CUST_CombinedNumber" SortExpression="CUST_CombinedNumber" HeaderText="Number">
<HeaderStyle Width="60px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="CUST_Name" SortExpression="CUST_Name" HeaderText="Name">
<HeaderStyle Width="200px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="DisplayIssueDate" SortExpression="MBI_Date" HeaderText="Effective">
<HeaderStyle Width="80px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="DisplayCancelDate" HeaderText="Cancel">
<HeaderStyle Width="80px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="MBI_Miles" HeaderText="Effective">
<HeaderStyle Width="60px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="CNCL_CancelMiles" HeaderText="Cancel">
<HeaderStyle Width="60px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="MBI_Price" HeaderText="Price" DataFormatString="{0:C}">
<HeaderStyle Width="40px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="CNCL_CalculatedNetRefund" HeaderText="Price Refund" DataFormatString="{0:C}">
<HeaderStyle Width="40px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="MBI_DlrCost" HeaderText="Cost" DataFormatString="{0:C}">
<HeaderStyle Width="40px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="CNCL_CalculatedNetAdminRefund" HeaderText="Cost Refund" DataFormatString="{0:C}">
<HeaderStyle Width="40px"></HeaderStyle>
</asp:BoundColumn>
</Columns>
<PagerStyle VerticalAlign="Top" NextPageText=">>>>" Height="18px" PrevPageText="<<<<"
HorizontalAlign="Left" ForeColor="White" BackColor="Blue" Wrap="False"></PagerStyle>
</asp:datagrid>
<asp:Label ID="Errormsg" runat="server" ForeColor="#CC0000" ></asp:Label>
</asp:Content>

I figured my problem here. I had a class named "Invoice" on my dbml as well as a page named "Invoice.aspx". This is a WebSite Project as opposed to a WebApplication so .net was correct in saying "Compiler Error Message: BC30456: 'Theme' is not a member of 'ASP.invoice_aspx'." blah blah. I wonder why this doesn't show up locally. This site was working fine on my local box, this was showing up after publishing the site to a server. Anyways, this is now working. I just renamed the aspx page and repubbed. <~~if thats a word. lol
Thanks,
~ck in San Diego

Go into the property pages of the deployment project. Under the Compilation tab, uncheck the option "Allow this precompiled site to be updatable". This resolved the problem for me.

Never seen this one before, but I would start by double checking the version setting on virtual directory or website to make sure it is targeting the correct runtime.

Try this:
http://arjansworld.blogspot.com/2006/11/aspnet-20-tip-theme-is-not-member-of.html
Can you put the HTML code up here to let us take a look? Are you sure you cleaned all old DLL's out of the directory you deployed to?

I had the same issue. This has nothing to do with Themes. Check duplicate DLLS in your bin folder. You could remove the
', App_Web_1d5eb-af'
part of your inherit statement. But the issue is a duplicate library in the bin folder, As soon as you identify and delete/move them the error will go away. If not delete them all and rebuild, some remaining legacy dll could be the issue.

I had a similar issue. I found the solution here.
The problem happens when there are 2 partial classes with the same name in the project. In my case, I had renamed Home.aspx.vb to Home-OLD.aspx.vb and replaced it with another page named Home.aspx (and codebehind file). The problem is that I didn't rename the class within Home-OLD.aspx.vb so I had 2 classes named Home in the project.
I ended up commenting out the old Home-OLD.aspx and Home-OLD.aspx.vb code for now and it worked.

If you have validated you don't have a class name collision and you are using a dynamic compilation website, you may need to clear out the Temp ASP files. Review the full path of the error to the .dll and delete the folder it is contained in.
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ [your site] \ [random number] \ [your site dlls]
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\ [your site] \ [random number] \ [your site dlls]

Related

Gridview Paging is always on

I want to turn paging off on a gridview, however, I can't seem to turn it off and I don't understand hwy it is on to begin with.
This seems like such a basic issue, but I can't seem to find anyone having the same issue. I can find plenty of people having issues in turning paging on, but no one turning it off.
ASP.Net Code
<asp:TabContainer ID="tcQuestions" runat="server" Width="100%" ActiveTabIndex="2">
<asp:TabPanel ID="tpAll" runat="server" HeaderText="All Questions" ScrollBars="None">
<ContentTemplate>
<asp:UpdatePanel ID="upAll" runat="server">
<ContentTemplate>
<asp:GridView ID="gvAllQuestions" runat="server" DataSourceID="sdsQuestions" AutoGenerateColumns="False" AllowPaging="False" Width="100%">
<Columns>
<asp:HyperLinkField DataTextField="QuestionRef" HeaderText="Ref" DataNavigateUrlFields="FkSection,QuestionID" DataNavigateUrlFormatString="questions/{0}/{1}">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:HyperLinkField>
<asp:BoundField DataField="QuestionText" HeaderText="Question" />
<asp:BoundField DataField="Period" HeaderText="Frequency">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="ValidFrom" HeaderText="Start From" DataFormatString="{0:dd MMM yy}">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="ObsoleteDate" HeaderText="Next Review" DataFormatString="{0:dd MMM yy}">
<HeaderStyle Wrap="False" />
<ItemStyle Wrap="False" />
</asp:BoundField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="sdsQuestions" runat="server"
ConnectionString="<%$ ConnectionStrings:ApplicationConnectionString %>"
SelectCommand="SELECT QuestionID, QuestionRef, QuestionText, FkSection, Period, ValidFrom, ObsoleteDate FROM Questions WHERE [FkSection] = #SectionID ORDER BY Obsolete, ObsoleteDate Desc">
<SelectParameters>
<asp:ControlParameter ControlID="ddlSections" Name="SectionID" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:TabPanel>
There is no code behind affecting the gridview.

AjaxControlToolkit - GridView wont select - don't understand viewstate

Overview:
I have two text boxes at the top of this form for inputting a beginning/ending date.
In the middle of the form I have a gridview that is populated with rows based on those dates.
At the bottom of the form I have a report generated based on which row is selected in the grid.
I selected the BeginningDate and the EndingDate and the gridview becomes populated (working). When I click the "Select" button on a row in the grid something is happening that makes it break. The row isn't selected. I know this because the CSS thats usually applied (by default) to a selected row in the gridview is not applied.
Additionally in the code-behind I'm setting...
lblGridError.Text = gridJobsReport.SelectedIndex.ToString()
The page load even has the same code, so the label reads "-1" when the page loads but never changes when I click the select buttons on the gridview. Something is breaking my Async postbacks. I wish I understood viewstate better, I'm always suspicious of it being the culprit but honestly I have no idea.
<%# Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="BidReport.aspx.vb" Inherits="BidReport" %>
<%# Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<ajaxToolkit:ToolkitScriptManager ID="tsmgrJobsReport" runat="server"
CombineScripts="True">
</ajaxToolkit:ToolkitScriptManager>
<p>
Enter a date range to populate the Jobs Grid.</p>
<asp:UpdatePanel ID="uPanelForm" runat="server">
<ContentTemplate>
<table>
<tr>
<td style="text-align: right">
<asp:Label ID="lblBeginningDate" runat="server" Text="Beginning Date:"></asp:Label></td>
<td>
<asp:TextBox ID="txtBeginningDate" runat="server" AutoPostBack="True"
CausesValidation="True"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="txtBeginningDate_CalendarExtender"
runat="server"
TargetControlID="txtBeginningDate">
</ajaxToolkit:CalendarExtender>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvBeginningdate" runat="server"
ControlToValidate="txtBeginningDate"
ErrorMessage="You must enter the Beginning Date" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revBeginningDate" runat="server"
ControlToValidate="txtBeginningDate"
ErrorMessage="Posted Date must be in the format "DD/MM/YYYY""
Font-Bold="True" ForeColor="Red"
ValidationExpression="^([1-9]|1[012])/([1-9]|[12][0-9]|3[01])/(20\d\d)$">*</asp:RegularExpressionValidator>
</td>
<td rowspan="2">
<asp:CompareValidator ID="cvBeginDateLTEndDate" runat="server"
ControlToCompare="txtEndingDate" ControlToValidate="txtBeginningDate"
ErrorMessage="Beginning Date must be earlier than the Ending Date."
Font-Bold="True" ForeColor="Red" Operator="LessThan">*</asp:CompareValidator>
</td>
</tr>
<tr>
<td style="text-align: right">
<asp:Label ID="lblEndingDate" runat="server" Text="Ending Date:"></asp:Label></td>
<td>
<asp:TextBox ID="txtEndingDate" runat="server" AutoPostBack="True"
CausesValidation="True"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="txtEndingDate_CalendarExtender"
runat="server" TargetControlID="txtEndingDate">
</ajaxToolkit:CalendarExtender>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvEndingDate" runat="server"
ControlToValidate="txtEndingDate"
ErrorMessage="You must enter the EndingDate Date" Font-Bold="True"
ForeColor="Red">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revEndingDate" runat="server"
ControlToValidate="txtEndingDate"
ErrorMessage="Posted Date must be in the format "DD/MM/YYYY""
Font-Bold="True" ForeColor="Red"
ValidationExpression="^([1-9]|1[012])/([1-9]|[12][0-9]|3[01])/(20\d\d)$">*</asp:RegularExpressionValidator>
</td>
</tr>
</table>
<asp:ValidationSummary ID="valsumDates" runat="server" ForeColor="Red" />
<p>Click or Tap the "SELECT" button in the right column next to the Job you want and
a report will be generated below.</p>
<asp:GridView ID="gridJobsReport" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="PostingID" DataSourceID="sqlDSReportGrid"
ForeColor="#333333" GridLines="Horizontal"
ShowHeaderWhenEmpty="True" Width="100%">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="PostingID" HeaderText="PostingID" ReadOnly="True"
SortExpression="PostingID" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Department" HeaderText="Department"
SortExpression="Department" />
<asp:BoundField DataField="JobName" HeaderText="JobName"
SortExpression="JobName" />
<asp:BoundField DataField="Shift" HeaderText="Shift" SortExpression="Shift" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Needs" HeaderText="Needs"
SortExpression="Needs" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="PostedDate" HeaderText="PostedDate"
SortExpression="PostedDate" DataFormatString="{0:d}" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="PostedTime" HeaderText="Time"
SortExpression="PostedTime" DataFormatString="{0:t}" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ClosingDate" HeaderText="ClosingDate"
SortExpression="ClosingDate" DataFormatString="{0:d}" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ClosingTime" HeaderText="Time"
SortExpression="ClosingTime" DataFormatString="{0:t}" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:CommandField ButtonType="Button" CausesValidation="True"
ShowSelectButton="true" />
</Columns>
<EditRowStyle BackColor="#999999" />
<EmptyDataRowStyle HorizontalAlign="Center" />
<EmptyDataTemplate>
There is currently no data to display based on the date range provided.
</EmptyDataTemplate>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<br />
<asp:Label ID="lblGridError" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<ajaxToolkit:UpdatePanelAnimationExtender ID="uPanelForm_UpdatePanelAnimationExtender"
runat="server" TargetControlID="uPanelForm">
</ajaxToolkit:UpdatePanelAnimationExtender>
<p>You can print or save the report using the buttons at the top of the report.</p>
<asp:UpdatePanel ID="uPanelJobsReport" runat="server">
<ContentTemplate>
<rsweb:ReportViewer ID="rvJobsReport" runat="server" Width="100%">
</rsweb:ReportViewer>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gridJobsReport"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<asp:SqlDataSource ID="sqlDSReportGrid" runat="server"
ConnectionString="<%$ ConnectionStrings:JobsDB %>"
SelectCommand="SELECT dbo.tblJobPostings.PostingID, dbo.tblDepartments.Department, dbo.tblJobs.JobName,
dbo.tblJobPostings.Shift, dbo.tblJobPostings.Needs, dbo.tblJobPostings.PostedDate,
dbo.tblJobPostings.PostedTime, dbo.tblJobPostings.ClosingDate, dbo.tblJobPostings.ClosingTime
FROM dbo.tblJobPostings
INNER JOIN dbo.tblJobs ON dbo.tblJobPostings.JobID = dbo.tblJobs.JobID
INNER JOIN dbo.tblDepartments ON dbo.tblJobPostings.DeptID = dbo.tblDepartments.DeptID
WHERE dbo.tblJobPostings.ClosingDate >= #BeginningDate
AND dbo.tblJobPostings.ClosingDate <= #EndingDate
ORDER BY dbo.tblJobPostings.ClosingDate Asc">
<SelectParameters>
<asp:ControlParameter ControlID="txtBeginningDate" Name="BeginningDate"
PropertyName="Text" ConvertEmptyStringToNull="False" DefaultValue="" />
<asp:ControlParameter ControlID="txtEndingDate" Name="EndingDate"
PropertyName="Text" ConvertEmptyStringToNull="False" DefaultValue="" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sqlDSJobReport" runat="server"></asp:SqlDataSource>
</asp:Content>
I really don't understand why this worked, but I decided to try handling the dates manually with session variables and its working perfectly now. It doesn't matter if I mess with the session state on the update panels or any of the form elements it seems to work no matter what now.
I guess that after the initial asyncpostback the sqldatasource wasn't reading the values in the textboxes, or something. If anyone can explain what was going on in another "Answer Question" section I'll accept it.
If Page.IsPostBack Then
Session("sBeginningDate") = txtBeginningDate.Text
Sessoin("sEndingDate") = txtEndingDate.Text
txtBeginningDate.Text = Session("sBeginningdate")
txtEndingDate.Text = Session("sEndingDate")
Else
Session("sBeginningDate") = Now().AddDays(-14)
Session("sEndingDate") = Now()
txtBeginningDate.Text = Session("sBeginningDate").ToShortDateString
txtEndingDate.Text = Session("sEndingDate").ToShortDateString
End If

Question about ASP.NET gridviews

I have a gridview. Is it possible to modify the gridview so that I can have multiple rows in the column headers? For example, the following code generates the table in the picture below.
<asp:GridView ID="productsGridView" Runat="server" DataSourceID="productDataSource" AutoGenerateColumns="False" AllowSorting="True" BorderWidth="2px"
BackColor="White" GridLines="None" CellPadding="3" CellSpacing="1" BorderStyle="Ridge" BorderColor="White" AllowPaging="True">
<FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>
<PagerStyle ForeColor="Black" HorizontalAlign="Right" BackColor="#C6C3C6"></PagerStyle>
<HeaderStyle ForeColor="#E7E7FF" Font-Bold="True" BackColor="#4A3C8C"></HeaderStyle>
<Columns>
<asp:BoundField HeaderText="Product" DataField="ProductName" SortExpression="ProductName"></asp:BoundField>
<asp:BoundField HeaderText="Unit Price" DataField="UnitPrice" SortExpression="UnitPrice" DataFormatString="{0:c}">
<ItemStyle HorizontalAlign="Right"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Units In Stock" DataField="UnitsInStock" SortExpression="UnitsInStock" DataFormatString="{0:d}">
<ItemStyle HorizontalAlign="Right"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Quantity Per Unit" DataField="QuantityPerUnit"></asp:BoundField>
</Columns>
<SelectedRowStyle ForeColor="White" Font-Bold="True" BackColor="#9471DE"></SelectedRowStyle>
<RowStyle ForeColor="Black" BackColor="#DEDFDE"></RowStyle>
</asp:GridView>
This table only has one row in the column header. What I am looking for is something like this:
Any Ideas on how I can achieve this? Is this even possible?
If you use a TemplateField instead, you can control the header template as well, which can be custom ASPX markup. The downside is that you have to display the data manually with Labels instead of using the simpler BoundField properties. However, this also allows you to layout the data in a custom layout to fit with the heading:
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Weight<br />
Date | Time<br />
Product
</HeaderTemplate>
<ItemTemplate>
<asp:Label runat="server" Text='<%#Eval("Weight") %>'></asp:Label><br />
<asp:Label runat="server" Text='<%#Eval("Date") %>'></asp:Label> |
<asp:Label runat="server" Text='<%#Eval("Time") %>'></asp:Label><br />
<asp:Label runat="server" Text='<%#Eval("Product") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>

set column width of a gridview in asp.net

I dragged and dropped a GridView from toolbox to Aspx page.the design code looks like this
<asp:GridView ID="gridview1" runat="server" style="text-align:center;width: 1327px;"
CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True"
EnableSortingAndPagingCallbacks="True" PageSize="50" AutoGenerateEditButton="True">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"
Height="12px" VerticalAlign="Bottom" Width="12px" Wrap="False" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
I have a column by name Address in database.The table is bound to this grid view using following VB.NET code
Dim ds as Data.DataSet
Dim da As New OleDbDataAdapter("select col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,Address from table, con)
da.Fill(ds)
gridviewrealestate.DataSource = ds
gridviewrealestate.DataBind()
Now,When the gridview is displayed,the columns are very close to each other due to large information present in Address Column.I want to set the Address Column to a particular width.
Please help me how to do this.
<asp:GridView ID="GridView1" runat="server">
<HeaderStyle Width="10%" />
<RowStyle Width="10%" />
<FooterStyle Width="10%" />
<Columns>
<asp:BoundField HeaderText="Name" DataField="LastName"
HeaderStyle-Width="10%" ItemStyle-Width="10%"
FooterStyle-Width="10%" />
</Columns>
</asp:GridView>
I know this is an old Question, but it popped up when I was looking for a solution to the same issue, so I thought that I would post what worked for me.
<asp:BoundField DataField="Description" HeaderText="Bond Event" ItemStyle-Width="300px" />
I used the ItemStyle-Width attribute on my BoundField and it worked very nicely I haven't had any issues yet.
I didn't need to add anything else to the rest of the code to make this work either.
Set width
HeaderStyle-width
for Example HeaderStyle-width="10%"
This what worked for me. set HeaderStyle-Width="5%", in the footer set textbox
width Width="15",also set the width of your gridview to 100%. following is the one of the column of my gridview.
<asp:TemplateField HeaderText = "sub" HeaderStyle-ForeColor="White" HeaderStyle-Width="5%">
<ItemTemplate>
<asp:Label ID="sub" runat="server" Font-Size="small" Text='<%# Eval("sub")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_sub" runat="server" Text='<%# Eval("sub")%>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txt_sub" runat="server" Width="15"></asp:TextBox>
</FooterTemplate>
You need to convert the column into a 'TemplateField'.
In Designer View, click the smart tag of the GridView, select-> 'Edit columns'.
Select your column you wish to modify and press the hyperlink converting it to a template. See screenshot:
Converting column to template.
Note: Modifying your datasource might regenerate the columns again, so it might make changes to your template columns.
Ref: https://msdn.microsoft.com/en-us/library/bb288032.aspx
Add HeaderStyle-Width and ItemStyle-width to TemplateFiels
<asp:GridView ID="grdCanceled" runat="server" AutoGenerateColumns="false" OnPageIndexChanging="grdCanceled_PageIndexChanging" AllowPaging="true" PageSize="15"
CssClass="table table-condensed table-striped table-bordered" GridLines="None">
<HeaderStyle BackColor="#00BCD4" ForeColor="White" />
<PagerStyle CssClass="pagination-ys" />
<Columns>
<asp:TemplateField HeaderText="Mobile NO" HeaderStyle-Width="10%" ItemStyle-Width="10%">
<ItemTemplate>
<%#Eval("mobile") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name" HeaderStyle-Width="10%" ItemStyle-Width="10%">
<ItemTemplate>
<%#Eval("name") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City" HeaderStyle-Width="10%" ItemStyle-Width="10%">
<ItemTemplate>
<%#Eval("city") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Reason" HeaderStyle-Width="25%" ItemStyle-Width="25%">
<ItemTemplate>
<%#Eval("reson") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Agent" HeaderStyle-Width="10%" ItemStyle-Width="10%">
<ItemTemplate>
<%#Eval("Agent") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date" HeaderStyle-Width="10%" ItemStyle-Width="10%">
<ItemTemplate>
<%#Eval("date","{0:dd-MMM-yy}") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DList" HeaderStyle-Width="10%" ItemStyle-Width="10%">
<ItemTemplate>
<%#Eval("service") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="EndDate" HeaderStyle-Width="10%" ItemStyle-Width="10%">
<ItemTemplate>
<%#Eval("endDate","{0:dd-MMM-yy}") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="5%" ItemStyle-Width="5%">
<ItemTemplate>
<asp:CheckBox data-needed='<%#Eval("userId") %>' ID="chkChecked" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
There are two steps:
You must set an appropriate width for GridView like this: Width="2000px".
You can set width of Colum by setting [ItemStyle-Width] Like this: ItemStyle-Width="300px".
** You can set width by setting fixed Pixels like "150 px" or by percentage like"10%".
<asp:BoundField DataField="ElementName" HeaderText="RBI GL Name" ItemStyle-Horizontal ItemStyle-Width="50px" HeaderStyle-Width="50px"/>

ASP.NET CommandField & skin

I'm tying to skin ASP.NET GridView CommandField.
Everything si working fine, just when I move CommandField property declarations from page to skin file, the whole commandField properties are ignored. here is my skin file:
<asp:GridView
AllowPaging="true"
AllowSorting="false"
AutoGenerateEditButton="false"
AutoGenerateDeleteButton="false"
AutoGenerateSelectButton="false"
AutoGenerateColumns="false"
GridLines="None"
PageSize="20"
ShowFooter="false"
ShowHeader="true"
runat="server">
<Columns>
<asp:CommandField
ButtonType="Image"
ControlStyle-Width="25"
EditImageUrl="Images/Icons/pencil.png"
DeleteImageUrl="Images/Icons/cross.png"
/>
</Columns>
</asp:GridView>
In web.config I apply only StyleSheetTheme. Do I miss something?
Thanks
This can be achieved by using StyleSheetTheme and NOT Theme.
Following is the control style defined in a .skin file
<asp:GridView runat="server" Font-Names="verdana,arial,sans serif" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False" Width="95%">
<Columns>
<asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/Buttons/16x16/Cancel.gif"
EditImageUrl="~/Images/Buttons/16x16/Edit.gif" ShowEditButton="True" InsertImageUrl="~/Images/Buttons/16x16/New.gif" UpdateImageUrl="~/Images/Buttons/16x16/Update.gif" />
<asp:CommandField ButtonType="Image" DeleteImageUrl="~/Images/Buttons/16x16/Delete.gif"
ShowDeleteButton="True" />
</Columns>
<RowStyle Font-Size="Smaller" ForeColor="Black" />
<PagerStyle Font-Size="Smaller" ForeColor="Black" />
<SelectedRowStyle BackColor="Yellow" />
<HeaderStyle BackColor="#2D5C3D" Font-Size="Smaller" ForeColor="White" HorizontalAlign="left" />
<FooterStyle BackColor="#2D5C3D" />
<EditRowStyle BackColor="#2D5C3D" />
<AlternatingRowStyle BackColor="#ECE9D8" />
The web.config file defines the StyleSheetTheme as site level
<pages styleSheetTheme="Green" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
The .aspx page containing the GridView control
<asp:GridView ID="gvUser" runat="server" AutoGenerateColumns="False"
DataKeyNames="Id" onpageindexchanged="gvUser_PageIndexChanged"
onpageindexchanging="gvUser_PageIndexChanging"
onrowcancelingedit="gvUser_RowCancelingEdit" onrowdeleting="gvUser_RowDeleting"
onrowediting="gvUser_RowEditing" onrowupdating="gvUser_RowUpdating"
onselectedindexchanging="gvUser_SelectedIndexChanging" onsorted="gvUser_Sorted"
onsorting="gvUser_Sorting">
<Columns>
<asp:BoundField DataField="Id" HeaderText="User Id" >
<HeaderStyle HorizontalAlign="Right" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" />
</asp:BoundField>
</Columns>
</asp:GridView>
For detail please refer to the following
http://weblogs.asp.net/vimodi/ThemesFaqs
http://weblogs.asp.net/vimodi/WhatIs-StyleSheetTheme
Hope this helps!
I get:
Content of literal
<asp:CommandField
ButtonType="Image"
ShowDeleteButton="true"
ItemStyle-Width="25"
DeleteImageUrl="~/App_Themes/SimplaAdmin/Images/Icons/cross.png"
/>
is not allowed within a skin file.
If you want to use a Fontawesome icon, you can change it like that:
<asp:CommandField ButtonType="Link" ShowEditButton="true"
EditText="<i class='fas fa-edit'></i>" />
for Delete use:
DeleteText="<i class='fas fa-trash-alt'></i>"
for Canel use:
CancelText="<i class='fas fa-window-close'></i>"
for Update use:
UpdateText="<i class='fas fa-sync'></i>"
What happens if you move the CommandField tag outside of the GridView tag?
i.e.:
<asp:GridView
AllowPaging="true"
AllowSorting="false"
AutoGenerateEditButton="false"
AutoGenerateDeleteButton="false"
AutoGenerateSelectButton="false"
AutoGenerateColumns="false"
GridLines="None"
PageSize="20"
ShowFooter="false"
ShowHeader="true"
runat="server">
</asp:GridView>
<asp:CommandField
ButtonType="Image"
ControlStyle-Width="25"
EditImageUrl="Images/Icons/pencil.png"
DeleteImageUrl="Images/Icons/cross.png"
/>

Resources