Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 容器不存在_Html_Asp.net_Repeater_Flags - Fatal编程技术网

Html 容器不存在

Html 容器不存在,html,asp.net,repeater,flags,Html,Asp.net,Repeater,Flags,我在我的项目中使用转发器。。所以,当用户添加新文档时,我想突出显示与gmail相同的新添加文档,当我们在gmail帐户中看到新电子邮件时,电子邮件以粗体显示,然后我们可以看到有人发送与添加新记录时我想发送的相同的电子邮件,然后如何突出显示或以其他方式识别? 所以有人建议我对此使用标志,然后当我尝试首先使用标志时,我在表中添加如下列 然后当我在中继器中这样使用时 <tr style='<%if(DataBinder.Eval(Container.DataItem, "data

我在我的项目中使用转发器。。所以,当用户添加新文档时,我想突出显示与gmail相同的新添加文档,当我们在gmail帐户中看到新电子邮件时,电子邮件以粗体显示,然后我们可以看到有人发送与添加新记录时我想发送的相同的电子邮件,然后如何突出显示或以其他方式识别? 所以有人建议我对此使用标志,然后当我尝试首先使用标志时,我在表中添加如下列

然后当我在中继器中这样使用时

 <tr
   style='<%if(DataBinder.Eval(Container.DataItem, "datatype")== 1) 
    { %> background-color: yellow;  <% }
     else { %> background-color: white;
     <%} %>'>

这说明我有错误

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: CS0103: The name 'Container' does not exist in the current context
Source Error                    
                      Line 124:<%--                            <tr>--%>
Line 125:                            <tr
Line 126:                                  style='<% if (DataBinder.Eval(Container.DataItem, "datatype")== 1) { %> background-color: yellow;  <% }
编译错误
描述:测试过程中发生错误
编译服务此请求所需的资源。请
查看以下特定错误详细信息并修改源代码
适当地。
编译器错误消息:CS0103:当前上下文中不存在名称“Container”
源错误
第124行:

第125行:您正在执行的是在ASP.NET Webforms中不起作用的内联代码

您可以为常规行和高亮显示行创建css类,并相应地应用该类。我将创建一个单独的函数,将“datatype”作为参数,并根据值返回css类名。然后从.aspx调用该函数以设置tr class属性

如所示。

请尝试以下操作:

HTML

<tr style='<%# getBackground(Eval("FieldName")) %>'>

这假定字段是布尔值,但您可以强制转换为任何基本数据类型或自定义数据类型。

字段名表示列名或其他名称?是的,我创建了单独的类库,然后在ASP.NET WEB应用程序中的引用中添加CLASSLIBRARY.DLL,当我尝试此操作时,在CLASSLIBRARY中公开字符串getbackground,然后添加此tr样式。。。在.aspx表单中,它向我显示了错误…“/”应用程序中的服务器错误。编译错误编译器错误消息:CS0103:名称“getBackground”在当前上下文中不存在源错误:第122行:第123行:第124行:FieldName将是列名。函数不能在类库中,它应该与我在表(有问题的pic)的column name(yes_no))中添加的.aspx file.column name相同或者别的什么?我尝试了这篇文章,它不能向我显示任何错误,但当我调试并添加新记录时,这不能向我显示任何效果…可能是你需要上传你的最新代码和更改,以便查看其中的错误。
public string getBackground(Object fieldName)
{
    if ((bool)fieldName)
    {
        return "background-color: yellow;";
    }
    else
    {
        return "background-color: white;";
    }
}