Object of type 'System.Boolean' cannot be converted to type 'System.Int16'.

I have a Checkbox on a detailsview bound to a small int field in my database table.

It binds fine when showing the item template on the detailsview, but when I try do an insert/update it blows up with that error.
Surely I can bind a checkbox to an integer field, so that unchecked translates to 0, and checked translates to 1?

The reason I use a smallint, is its future-proof.  If we decided to switch to a status instead off/on in the future, there are less changes required.

 

0
swaino
10/8/2007 12:43:47 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

6 Replies
1227 Views

Similar Articles

[PageSpeed] 10

As long as 0 is False and any other value is considered True you should be able to bind the value like this:

Checked='<%# Convert.ToBoolean(Eval("YourColumnNameHere")) %>'

-=JW=-
0
jamezw
10/8/2007 1:39:50 PM

Thanks! But the problem seems to exist not when displaying the data but pushing it back to the database.
So I guess, I need to change Eval to Bind, but when I did I got this error:

Name 'Bind' is not declared.

 

0
swaino
10/8/2007 1:59:23 PM
Can you show the update or insert code? You would need to explicitly send an int value back based on the checkbox's checked status.

-=JW=-
0
jamezw
10/8/2007 2:38:57 PM

 yes here it is:

 

<asp:MultiView ID="mvSiteLoc" runat="server">
            <asp:View ID="vwViewAll" runat="server">
                <asp:GridView ID="gvSiteLocs" runat="server" BackColor="White" BorderColor="#E7E7FF"
                    BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal" DataSourceID="SqlAllSitesDataSource"
                    AutoGenerateColumns="False" SelectedIndex="0" Width="662px" DataKeyNames="locId" AllowPaging="True">
                    <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                    <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Left" />
                    <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
                    <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                    <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                    <AlternatingRowStyle BackColor="#F7F7F7" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="locName" HeaderText="Site" SortExpression="locName" />
                        <asp:BoundField DataField="armAreaName" HeaderText="Area" SortExpression="armAreaName" />
                        <asp:BoundField DataField="rgmRegionName" HeaderText="Region" SortExpression="rgmRegionName" />
                        <asp:BoundField DataField="locEmail" HeaderText="Site Email" SortExpression="locEmail" />
                        <asp:BoundField DataField="locManager" HeaderText="Manager" SortExpression="locManager" />
                        <asp:BoundField DataField="locShortName" HeaderText="Short Name" SortExpression="locShortName" />
                        <asp:BoundField DataField="locVamosId" HeaderText="Vamos Id" SortExpression="locVamosId" />
                        <asp:BoundField DataField="locNotifySiteAdminSupp" HeaderText="Site Admin - Suppress notification"
                            SortExpression="locNotifySiteAdminSupp" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlAllSitesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:247Db %>"
                    SelectCommand="usp_Loc_SelectWithAreaRegions" SelectCommandType="StoredProcedure">
                </asp:SqlDataSource>
                <br />
                <br />
                <asp:DetailsView ID="dvSiteLoc" runat="server" Height="50px" Width="369px"
                    AutoGenerateRows="False" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None"
                    BorderWidth="1px" CellPadding="3" DataKeyNames="locId" DataSourceID="SiteLocDataSource"
                    GridLines="Horizontal">
                    <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                    <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" Width="10px" />
                    <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
                    <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                    <Fields>
                        <asp:BoundField DataField="locId" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                            SortExpression="locId" />
                        <asp:TemplateField HeaderText="Area" SortExpression="locAreaId">
                            <EditItemTemplate>
                                <asp:DropDownList ID="ddlArea" runat="server" AppendDataBoundItems="True"
                                    Width="141px" DataSourceID="AreaDataSource" DataTextField="armAreaName" DataValueField="armId" SelectedValue='<%# Bind("locAreaId") %>'>
                                    <asp:ListItem></asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="rfvReqArea" runat="server" ControlToValidate="ddlArea"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate><asp:DropDownList ID="ddlArea" runat="server" AppendDataBoundItems="True" DataSourceID="AreaDataSource"
                                    DataTextField="armAreaName" DataValueField="armId" SelectedValue='<%# Bind("locAreaId") %>'
                                    Width="141px">
                                <asp:ListItem Selected="True"></asp:ListItem>
                            </asp:DropDownList><asp:RequiredFieldValidator ID="rfvReqArea" runat="server" ControlToValidate="ddlArea"
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:DropDownList ID="ddlArea" runat="server" AppendDataBoundItems="True" Enabled="False"
                                    Width="141px" DataSourceID="AreaDataSource" DataTextField="armAreaName" DataValueField="armId" SelectedValue='<%# Bind("locAreaId") %>'>
                                    <asp:ListItem></asp:ListItem>
                                </asp:DropDownList> 
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Map Zone" SortExpression="locMapZone">
                            <EditItemTemplate>
                                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="MapZonesDataSource"
                                    DataTextField="mpzZoneName" DataValueField="mpzId" SelectedValue='<%# Bind("locMapZone") %>'
                                    Width="141px">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="rfvMapZone" runat="server" ControlToValidate="DropDownList1"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="MapZonesDataSource"
                                    DataTextField="mpzZoneName" DataValueField="mpzId" SelectedValue='<%# Bind("locMapZone") %>'
                                    Width="141px">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="rfvMapZone" runat="server" ControlToValidate="DropDownList1"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="MapZonesDataSource"
                                    DataTextField="mpzZoneName" DataValueField="mpzId" Enabled="False" SelectedValue='<%# Bind("locMapZone") %>'
                                    Width="141px">
                                </asp:DropDownList>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Site Location" SortExpression="locName">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("locName") %>'></asp:TextBox><asp:RequiredFieldValidator
                                    ID="rfvSiteLoc" runat="server" ControlToValidate="TextBox2" ErrorMessage="*">*</asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("locName") %>' MaxLength="50"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvSiteLoc" runat="server" ControlToValidate="TextBox1"
                                    ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("locName") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Email" SortExpression="locEmail">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" MaxLength="50" Text='<%# Bind("locEmail") %>'
                                    Width="200px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvEmail" runat="server" ControlToValidate="TextBox1"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="revEmail" runat="server" ControlToValidate="TextBox1"
                                    ErrorMessage="* Enter valid email" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("locEmail") %>' MaxLength="50" Width="200px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvEmail" runat="server" ControlToValidate="TextBox2"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="revEmail" runat="server" ControlToValidate="TextBox2"
                                    ErrorMessage="* Enter valid email" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("locEmail") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Manager's Name" SortExpression="locManager">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox3"  MaxLength="50" runat="server" Text='<%# Bind("locManager") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvManager" runat="server" ControlToValidate="TextBox3"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="TextBox3" MaxLength="50"  runat="server" Text='<%# Bind("locManager") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvManager" runat="server" ControlToValidate="TextBox3"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Bind("locManager") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Site Short Name" SortExpression="locShortName">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox4" runat="server" width="50px" Text='<%# Bind("locShortName") %>' MaxLength="2"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv" runat="server" ControlToValidate="TextBox4"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="TextBox4" runat="server" width="50px" maxlength="2" Text='<%# Bind("locShortName") %>' CausesValidation="True"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv" runat="server" ControlToValidate="TextBox4"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label4" runat="server" Text='<%# Bind("locShortName") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Vamosoft ID" SortExpression="locVamosId">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("locVamosId") %>' MaxLength="6" Width="50px"></asp:TextBox> 
                                <asp:RangeValidator ID="rgvVamosId" runat="server" ControlToValidate="TextBox5" ErrorMessage="* Enter value"
                                    MinimumValue="0" MaximumValue="999999" Type="Integer"></asp:RangeValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("locVamosId") %>' Width="50"></asp:TextBox>
                           <asp:RangeValidator ID="rgvVamosId" runat="server" ControlToValidate="TextBox5" ErrorMessage="* Enter value"
                                    MinimumValue="0" MaximumValue="999999" Type="Integer"></asp:RangeValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label5" runat="server" MaxLength="6" Text='<%# Bind("locVamosId") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Suppress Notifications to Site Admin" SortExpression="locNotifySiteAdminSupp">
                            <EditItemTemplate>
                                 <asp:CheckBox ID="Suppress" runat="server" Checked='<%# Bind("locNotifySiteAdminSupp") %>' />
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:CheckBox ID="Suppress" runat="server" Checked='<%# Bind("locNotifySiteAdminSupp") %>' />
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Convert.ToBoolean(Eval("locNotifySiteAdminSupp")) %>' enabled="false"/>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:CommandField ButtonType="Image" CancelImageUrl="~/App_Themes/247Theme/images/rd_btns/sm2_cancel.gif"
                            DeleteImageUrl="~/App_Themes/247Theme/images/rd_btns/sm2_Delete.gif" EditImageUrl="~/App_Themes/247Theme/images/rd_btns/sm2_edit.gif"
                            InsertImageUrl="~/App_Themes/247Theme/images/rd_btns/sm2_insert.gif" NewImageUrl="~/App_Themes/247Theme/images/rd_btns/sm2_New.gif"
                            ShowEditButton="True" ShowInsertButton="True" UpdateImageUrl="~/App_Themes/247Theme/images/rd_btns/sm2_update.gif" ShowDeleteButton="True" />
                    </Fields>
                    <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                    <AlternatingRowStyle BackColor="#F7F7F7" />
                    <EmptyDataTemplate>
                        <div id="graphicHeading">
                            <asp:Image ID="Image1" runat="server" ImageUrl="~/App_Themes/247Theme/images/msgicons/info_icon_md.png" />
                            <strong>No Locations currently exist.</strong>
                            <br />
                        </div>
                        Click <strong>Create New</strong> to add one.<br />
                        <br />
                        <asp:Button ID="btnCreateNew" runat="server" OnClick="btnCreateNew_Click" Text="Create New" />
                    </EmptyDataTemplate>
                    <FieldHeaderStyle HorizontalAlign="Left" />
                </asp:DetailsView>
        <asp:ObjectDataSource ID="SiteLocDataSource" runat="server"
            SelectMethod="usp_Loc_SelectLoc" TypeName="MainAppDataSetTableAdapters.tfs_SiteLocTableAdapter"
            UpdateMethod="Update" DeleteMethod="Delete">
            <UpdateParameters>
                <asp:Parameter Name="locAreaId" Type="Int64" />
                <asp:Parameter Name="locName" Type="String" />
                <asp:Parameter Name="locId" Type="Int64" />
                <asp:Parameter Name="locMapZone" Type="Int64" />
                <asp:Parameter Name="locEmail" Type="String" />
                <asp:Parameter Name="locManager" Type="String" />
                <asp:Parameter Name="locShortName" Type="String" />
                <asp:Parameter Name="locVamosId" Type="Int64" />
                <asp:Parameter Name="locNotifySiteAdminSupp" Type="Int16" />
            </UpdateParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="gvSiteLocs" Name="locId" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="locId" Type="Int64" />
            </DeleteParameters>
        </asp:ObjectDataSource>
                <asp:ObjectDataSource ID="AreaDataSource" runat="server" DeleteMethod="Delete" InsertMethod="Insert" SelectMethod="GetData" TypeName="MainAppDataSetTableAdapters.tfs_AreaManagerTableAdapter"
                    UpdateMethod="Update">
                    <DeleteParameters>
                        <asp:Parameter Name="Original_armId" Type="Int64" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="armUserId" Type="Object" />
                        <asp:Parameter Name="armAreaName" Type="String" />
                        <asp:Parameter Name="armRgmId" Type="Int64" />
                        <asp:Parameter Name="armFName" Type="String" />
                        <asp:Parameter Name="armSName" Type="String" />
                        <asp:Parameter Name="armEmail" Type="String" />
                        <asp:Parameter Name="armPhone" Type="String" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:Parameter Name="armUserId" Type="Object" />
                        <asp:Parameter Name="armAreaName" Type="String" />
                        <asp:Parameter Name="armRgmId" Type="Int64" />
                        <asp:Parameter Name="armFName" Type="String" />
                        <asp:Parameter Name="armSName" Type="String" />
                        <asp:Parameter Name="armEmail" Type="String" />
                        <asp:Parameter Name="armPhone" Type="String" />
                    </InsertParameters>
                </asp:ObjectDataSource>
                <asp:ObjectDataSource ID="MapZonesDataSource" runat="server" InsertMethod="Insert" SelectMethod="GetData" TypeName="MainAppDataSetTableAdapters.tfs_MapZonesTableAdapter">
                    <InsertParameters>
                        <asp:Parameter Name="mpzZoneName" Type="String" />
                        <asp:Parameter Name="mpzImgUrl" Type="String" />
                        <asp:Parameter Name="mpzNavUrl" Type="String" />
                        <asp:Parameter Name="mpzStatus" Type="Int16" />
                    </InsertParameters>
                </asp:ObjectDataSource>
            </asp:View>
            <asp:View ID="vwError" runat="server">
                 <div class="warningbox">
                    <h1>
                        Could not carry out this operation!</h1>
                    <p>
                        Unfortunately, this operation failed.<br />
                        <br />
                        Perhaps you are attempting to delete an existing location that is already in use
                        within a job role.</p>
                    <div class="btns">
                        <asp:ImageButton ID="imbOk" runat="server" ImageUrl="~/App_Themes/247Theme/images/rd_btns/sm2_ok.gif" />
                    </div>
                </div>
            </asp:View>
            <asp:View ID="vwNoData" runat="server">
                 <div class="warningbox">
                    <h1>
                        No Areas Set-up</h1>
                    <p>
                        To add a new site location you must first create at least one new area manager for
                        the site location to belong to.</p>
                    <div class="btns">
                        <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/App_Themes/247Theme/images/rd_btns/sm2_ok.gif"
                            PostBackUrl="~/WelcomeRedirect.aspx" />
                    </div>
                </div>
            </asp:View>
        </asp:MultiView>
  
0
swaino
10/8/2007 2:42:29 PM

I did a simple test. I bound a smallint field to a checkbox in a DetailsView and the update worked fine. The conversion was done automatically by the framework. I did notice from looking at your code this though: on your SiteLocDataSource object you show the UpdateMethod as:

UpdateMethod="Update"

Shouldn't this attribute contain the name of your stored procedure, similar to your SelectMethod which is:

SelectMethod="usp_Loc_SelectLoc"

-=JW=-
0
jamezw
10/8/2007 3:10:02 PM

The basic 4 commands; select, update, insert & delete are auto-generated by the table adapter in studio and also auto-generated into sprocs.  On the table adapter,  these commands including 'update' resolve to the stored procedures (e.g. Update --> usp_Loc_SelectLoc) and don't explicitly appear as separate functions on the table adapter.  If I add a specific stored procedure not included in those 4, then I would use the sproc name on the adapter.

Anyway, back to the point. I've realised what the problem was.  On the table adapter, I manually added each column and I missed specifying the source for each new column on the table adapter (including the on/off checkbox column).  Even though the datatype was set correctly it didn't like the fact it wasn't mapped to a field in the table.  Strange that it flagged that it couldn't convert it to an integer if it didn't know which column it came from, although maybe this was because the data type had been specified.

thanks for your help. 

 


 


0
swaino
10/8/2007 3:58:14 PM
Reply:

Similar Artilces:

Object of type 'System.DBNull' cannot be converted to type 'System.DateTime'.
Hi, How can I pass null values to a system.datetime? Thanks in advance for the help J   Below is my code:   Public Class Courses     Public Sub Update_Class(ByVal ClassId As Integer, _    ByVal StatusId As Integer, _    ByVal ClassNumber As Integer, _    ByVal TeacherId As Integer, _    ByVal AmountofParticipants As Integer, _    ByVal CourseDate1 As DateTime, _    ByVal CourseDate2 As DateTime, _    ByVal CourseDate3 As DateTime)     Dim myConnection As New SqlConnection(Conn...

Object of type 'System.DBNull' cannot be converted to type 'System.String' from formview
I have a formview that I am using for input to my datatable.  I am using an objectdatasource that uses a BLL.  This in turn points to my XSD tableadapter. When I test, and only fill in the required fields, I am getting the error Object of type 'System.DBNull' cannot be converted to type 'System.String' I am not sure what field is having the issue.  In my BLL for the Add, I have checked the dates for null and placed the value of DateTime.MinValue.  For the text fields, I have place "" if they are null.  Is this error being create prior to...

System.InvalidCastException: Unable to cast object of type 'System.Web.HttpInputStream' to type 'System.IO.FileStream'
I am trying to create a webpage that takes a file that someone want to upload and chop the file into smaller pieces, and then put back together again.  I have been trying to convert some code I found on Codeproject (FileSplitMerge).  They did it with VB which is what I want to use but it is a project not a web site so...  The problem that I am running into is I keep getting an error when I try to set: FileStream = HttpPostedFile.InputStream (I am using variables in my code) but I keep getting an error of: System.InvalidCastException: Unable to cast object of type 'Sys...

Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'.
Hello, I get this lovely error whenever I attempt to load an AJAXToolKit ScriptManager. It is the only one I have on the page. If I use the regulare script manager, my extenders don't detect it. I'm placing the ScriptManager just after the <Form> tag. The frustrating part is that it works when I preview it in the browser from my development machine it works, but once I place it the live server, it crashes on me . I've installed all of the .dlls in the proper places. Also, I'm trying to attempt to do this when creating a new site with the AJAX ToolKit enabled templat...

Unable to cast object of type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection' to type 'System.Web.Configuration.ScriptingScriptResourceHandlerSection'.
Hello, I get this lovely error whenever I attempt to load an AJAXToolKit ScriptManager. It is the only one I have on the page. If I use the regulare script manager, my extenders don't detect it. I'm placing the ScriptManager just after the <Form> tag. The frustrating part is that it works when I preview it in the browser from my development machine it works, but once I place it the live server, it crashes on me . I've installed all of the .dlls in the proper places. Also, I'm trying to attempt to do this when creating a new site with the AJAX ToolKit enabled templat...

Unable to cast object of type 'System.Web.Compilation.BuildResultCompiledAssembly' to type 'System.Web.Compilation.BuildResultCompiledGlobalAsaxType'
I always get the below exception if I make a configuration change to the web.config file then request a page without re-building the project. Exception: Unable to cast object of type 'System.Web.Compilation.BuildResultCompiledAssembly' to type 'System.Web.Compilation.BuildResultCompiledGlobalAsaxType'. Stack Trace: [InvalidCastException]: Unable to cast object of type 'System.Web.Compilation.BuildResultCompiledAssembly' to type 'System.Web.Compilation.BuildResultCompiledGlobalAsaxType'.   at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrec...

Unable to cast object of type 'System.Web.Configuration.ScriptingAuthenticationServiceSection' to type 'System.Web.Configuration.ScriptingAuthenticationServiceSection'.
I have tried to upgrade an existing application from VS2005 to VS2008.  I downloaded the latest AjaxControlToolkit and referenced it in my project.  I'm getting the below error when I try to deploy to our QA servers.  I'm NOT seeing the issue on our local development machines that have VS2008 installed.   Unable to cast object of type 'System.Web.Configuration.ScriptingAuthenticationServiceSection' to type 'System.Web.Configuration.ScriptingAuthenticationServiceSection'.  What piece am I missing in the deployment?  All the w...

ERROR: Unable to cast object of type 'System.Boolean' to type 'System.String'
I created a class to update, insert, select and delete data with an object data source but I am getting the following error... body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-wei...

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'.
Hi, any idea why I'm getting the following error?Line 45: protected void CartGrid_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) Line 46: { Line 47: TextBox QuantityTextBox = (TextBox)CartGrid.Rows[e.RowIndex].Cells[2].Controls[0]; Line 48: int Quantity = Convert.ToInt32(QuantityTextBox.Text); Line 49: Are you sure that the control at CartGrid.Rows[e.RowIndex].Cells[2].Controls[0] isn't a LiteralControl?  How are you creating code this in your code?Brent JenkinsASP.NET, C#, Web Developerwww.valewebdesign.co.uk  ...

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'
Hello, Goal: enter a number in two fields HoursPerUnit and PeoplePerUnit and the value for the third field, TotalHoursPerUnit will populate after the the number in the two fields have been caculated.  Using the code below I receive the error message above.  Please tell me what am I doing wrong? Do I need to cast the text as a literal?  Please help? Thank you in advance, <%@ Page Language="VB" MasterPageFile="Default.master" AutoEventWireup="false" CodeFile="frmHR.aspx.vb" Inherits="frmHR"...

Unable to cast object of type 'System.Boolean' to type 'System.Data.SqlClient.SqlParameter'.
In my code this doesn't work:prms(0) = New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int).value = 2I get the error:Unable to cast object of type 'System.Boolean' to type 'System.Data.SqlClient.SqlParameter'. But this does: prms(0) = New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int)prms(0).Value = 2Any reason why?  You code prms(0) = New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int).value = 2 do evaluation: 1. if New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int).value = 2, the result is Yes or No, 2. prms(0) =...

Help Required
Server Error in '/' Application.--------------------------------------------------------------------------------Unable to cast object of type 'System.Web.Compilation.BuildResultCompiledAssembly' to type 'System.Web.Util.ITypedWebObjectFactory'. [InvalidCastException: Unable to cast object of type 'System.Web.Compilation.BuildResultCompiledAssembly' to type 'System.Web.Util.ITypedWebObjectFactory'.] System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +123 System.Web.Compilation.BuildMa...

Unable to cast object of type 'System.Web.UI.WebControls.FormView' to type 'System.Web.UI.WebControls.DropDownList'.
Hi,  I have a formview with a dropdownlist created dynamically. i want to determine whether the dropdownlist was clicked. the code is written in the FormView1_DataBound method. I get the following error in the line below that is in italics and underlined: Unable to cast object of type 'System.Web.UI.WebControls.FormView' to type 'System.Web.UI.WebControls.DropDownList'.   Here is my code: ddl_iFullname = New DropDownList ddl_iFullname.ID = "ddl_iFullname" ddl_iFullname.DataSource = ObjectDataSource3 ddl_iFullname.DataTextField = "fullname" ddl_iFullname.DataValueField = "...

Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TextBox'
I am attempting to "Update" a field in a Datagrid, but no matter what I do (Using either Label or Text Boxes)  I keep getting the same error: Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TextBox' The Error is highlighted below in the Sub... <==THE FIELD THAT CALLS THE ERROR  Any help would be greatly appreciated !!! Thanks !!   The code is as follows... <table border=0 height=210 bordercolor=olive ><tr valign=top><td> <asp:datagrid id="FacilityDataGrid"...

Web resources about - Object of type 'System.Boolean' cannot be converted to type 'System.Int16'. - asp.net.web-forms

Resources last updated: 11/21/2015 2:35:32 AM