错误:字符文字asp.net中的字符过多 [英] Error: too many characters in character literal asp.net

查看:80
本文介绍了错误:字符文字asp.net中的字符过多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将数据绑定到数据列表时出现此错误asp.net字符文字中的字符过多

I'm getting this error while binding data to data list too many characters in character literal asp.net

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="android.aspx.cs" Inherits="finalproject.android" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
.style1
{
    width:900px;
}
.style2
{
    width:633px;
    text-align:left;
}
.style4
{
    width:185px;
    text-align:center;
}
</style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:DataList ID="DataList1" runat="server" DataKeyField="modelid" 
        style="text-align: center; color: #333333;" RepeatColumns="3"
        Width="283px" DataSourceID="SqlDataSource2" CellPadding="3" 
    BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" 
    CellSpacing="1" >
        <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
        <ItemStyle BackColor="#DEDFDE" ForeColor="Black" />
        <ItemTemplate>
            <br />
            <div align="left"></div>
            <table cellspacing="1" class="style4" style="border:1px ridge #9900FF">
                <tr>
                    <td style="border-bottom-style:ridge; border-width: 1px; border-color: #000000">
                        <asp:Label ID="Label1" runat="server" Text="<%# Eval('brand') %>"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:ImageButton ID="ImageButton1" runat="server" Height="252px"
                            ImageUrl="<%# Image %>" style="margin-left: 0px" />
                    </td>
                </tr>
                <tr>
                    <td>
                        ModelID<asp:Label ID="Label2" runat="server" Text="<%# Eval('modelid') %>"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
                            CommandArgument="<%# Bind('ModelID') %>" Text="Add to Cart" Width="100%" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px" />
                    </td>
                </tr>
            </table>
            <br />
        </ItemTemplate>
        <SelectedItemStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
    </asp:DataList>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:VISHConnectionString2 %>" 
    SelectCommand="SELECT [Image], [modelid], [brand] FROM [adddetails]">
</asp:SqlDataSource>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table align="left" class="style2">
                <tr>
                    <td>
                        <asp:Label ID="Label3" runat="server" style="color: #333333"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

将数据绑定到数据列表时出现此错误asp.net字符文字中的字符过多

I'm getting this error while binding data to data list too many characters in character literal asp.net

推荐答案

字符文字中的字符过多"是由于其中的字符字面过多而引起的.

"too many characters in character literal" is caused by having a char-literal with too many characters in it.

您可能混淆了'-字符和"-字符.

You have probably mixed up the '-character and the "-character.

错误可能出在您的"android.aspx.cs"文件中,而不是您提供的.aspx文件中.

The error probably lies in your "android.aspx.cs"-file rather than the .aspx-file that you have provided.

您能提供相应的代码吗?

Could you provide the code for that as well?

好吧,您的问题就在这里:

Well, your problems are right here:

<%# Bind('ModelID') %>

用双引号替换单引号,您会变得很高兴!

Replace your single-quotes with double-quotes and you will be golden!

<%# Bind("ModelID") %>

您的所有评估/绑定都适用

Same goes for all your Evals/Binds

也请参见以下问题:

为什么我会收到CS1012:字符文字中的字符太多";和CS0019?

字符文字中的字符太多了吗?

这篇关于错误:字符文字asp.net中的字符过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆