dim str as string
str=字段 
if isdbnull(字段) or 字段="无" then 
    str="无地址"
end if
显示str

解决方案 »

  1.   

    <%# Container.dataitem("name")%>为Repeater控件的字段内容,在<html><body>中,应该怎么写你上面的语句呢?</body></html>我刚开始学,不会的地方很多,不好意思,麻烦了!
      

  2.   

    这是我写的可是不对<%# if isnull(Container.dataitem("from")) or Container.dataitem("from")="无" then%>无地址
    <%# else%>
    <%# Container.dataitem("from")%>
    <%# end if%>
      

  3.   

    这样写也不对呀,<table cellpadding="3" cellspacing="3">
    <tr>
       <td><%# Container.dataitem("name")%>来自
           <%# if isdbnull(Container.dataitem("from")) or Container.dataitem("from")="无" then//为错误行
         Response.Write("无地址")
      else
                  Container.dataitem("from")
              end if%>的留言
       </td>
    </tr>
    </table>出现错误:编译错误 
    说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: BC30201: 需要表达式。
    行 39:<tr>
    行 40:<td><%# Container.dataitem("name")%>来自
    <font color=#ff0000>行 41:<%# if isdbnull(Container.dataitem("from")) or Container.dataitem("from")="无" then</font>
    行 42:Response.Write("无地址")
    行 43:else
      

  4.   

    <table cellpadding="3" cellspacing="3">
    <tr>
       <td><%# JudgeNull(Container.dataitem("name"))%>
       </td>
    </tr>
    </table>Public Shared Function ShowUrl(ByVal showmsg As String) As String
     string tempstr="";
       if isdbnull(Container.dataitem("from")) or Container.dataitem("from")="无" then
                 tempstr="无地址"
      else
                  tempstr=showmsg
              end if
       return tempstr
    End Function
      

  5.   

    try:
    <%# if Container.dataitem("from") is nothing or Container.dataitem("from")="无" then
         Response.Write("无地址")
      else
                  Response.Write(Container.dataitem("from"))
              end if%>
      

  6.   

    不好意思。写错啦。正确如下。
    <table cellpadding="3" cellspacing="3">
    <tr>
       <td><%# JudgeNull(Container.dataitem("name").ToString())%>
       </td>
    </tr>
    </table>.vb
    Public Shared Function JudgeNull(ByVal showmsg As String) As String
     string tempstr="";
       if isdbnull(Container.dataitem("from")) or Container.dataitem("from")="无" then
                 tempstr="无地址"
      else
                  tempstr=showmsg
              end if
       return tempstr
    End Function
      

  7.   

    Public Shared Function ShowUrl(ByVal showmsg As String) As String
     string tempstr="";
       if isdbnull(Container.dataitem("from")) or Container.dataitem("from")="无" then
                 tempstr="无地址"
      else
                  tempstr=showmsg
              end if
       return tempstr
    End Function
    这段代码是放在*.apsx.vb页面里嘛?不是放在那是放在那里呢?
    定义的tempstr要怎么样才能引用呢?
    库中有N条记录,可以自动循环嘛?
    不好意思,太笨了,刚开始学什么都不懂!
      

  8.   

    happyno7(啤酒罐) 你说的这种写法也不对嘛,还是说上面的那个错误,那个try:是在什么地方用呀?
      

  9.   

    meetweb(niky)你写的这个也不对的呀,把那段代码放在.v是里面,它说名称“Container”未声明,不可以生成文件的呀,是我放的地方不对嘛?
      

  10.   

    假设这样,你的文件名如下,你库中有N条记录,可以自动循环嘛?
    如果你使用DataGrid来绑定的话。可以自动循环的。。
    如还发现问题把你的代码全部贴上。。
    showname.aspx
    <asp:datagrid id="DataGrid1" runat="server" AllowPaging="True" PageSize="2" AutoGenerateColumns="False" Width="100%">
    <Columns>
    <asp:TemplateColumn HeaderText="xxx">
    <ItemTemplate>
    <asp:Label runat="server" Text='<%#  JudgeNull(DataBinder.Eval(Container,"DataItem.name").ToString())  %>' ID="Label7">
    </asp:Label>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    <PagerStyle Mode="NumericPages"></PagerStyle>
    </asp:datagrid>showname.aspx.vb
    Public Shared Function JudgeNull(ByVal showmsg As String) As String
     string tempstr="";
       if isdbnull(Container.dataitem("from")) or Container.dataitem("from")="无" then
                 tempstr="无地址"
      else
                  tempstr=showmsg
              end if
       return tempstr
    End Function