【问题标题】:How to display text based on condition如何根据条件显示文本
【发布时间】:2015-09-28 14:51:05
【问题描述】:
If Request("cid") = 15 'Hudson Health Plan
    e.Row.Cells(11).Text = "<A href='http://myintra1/checkfile.aspx?id=90' target='_blank'>Click here for participating providers and the provider participating location/s.  </a> <br/>" & e.Row.Cells(11).Text
End If
If Request("cid") = 57 Then 'Hudson Health Plan
    e.Row.Cells(11).Text = "<A href='http://myintra1/checkfile.aspx?id=23' target='_blank'>Click here for participating providers and the provider participating location/s.  </a> <br/>" & e.Row.Cells(11).Text
End If

The above code shows correctly...

If Request("cid") = 15 And e.Row.Cells(3).Text = "Y" Then   'Hudson Health Plan
    e.Row.Cells(11).Text = "<A href='http://myintra1/checkfile.aspx?id=90' target='_blank'>Click here for participating providers and the provider participating location/s.  </a> <br/>" & e.Row.Cells(11).Text
Else
    e.Row.Cells(11).Text = ""
End If
If Request("cid") = 57 And e.Row.Cells(3).Text = "Y" Then   'Health Plus Amerigroup/Empire BCBS
    e.Row.Cells(11).Text = "<A href='http://myintra1/checkfile.aspx?id=23' target='_blank'>Click here for participating providers and the provider participating location/s.  </a> <br/>" & e.Row.Cells(11).Text
Else
    e.Row.Cells(11).Text = ""
End If

The above code shows correctly but it does not concatenate the text like it did in the first section of code....

如果CID 匹配并且第三列是“Y”,我该如何解决这个问题,然后显示链接和文本。如果“CID”匹配并且第三列是“N”,则不显示任何内容。

【问题讨论】:

    标签: asp.net vb.net gridview


    【解决方案1】:

    假设第二张图片是cid = 57,首先执行else,单元格获取空值,然后执行第二张then,并将链接连接到一个之前清除的空值。要解决这一切,只需使用elseif

    If Request("cid") = 15 And e.Row.Cells(3).Text = "Y" Then   'Hudson Health Plan
        e.Row.Cells(11).Text = "<A href='http://myintra1/checkfile.aspx?id=90' target='_blank'>Click here for participating providers and the provider participating location/s.  </a> <br/>" & e.Row.Cells(11).Text
    Elseif Request("cid") = 57 And e.Row.Cells(3).Text = "Y" Then   'Health Plus Amerigroup/Empire BCBS
        e.Row.Cells(11).Text = "<A href='http://myintra1/checkfile.aspx?id=23' target='_blank'>Click here for participating providers and the provider participating location/s.  </a> <br/>" & e.Row.Cells(11).Text
    Else
        e.Row.Cells(11).Text = ""
    End If
    

    【讨论】:

      【解决方案2】:

      如果只需要在e.Row.Cells(3).Text中满足“Y”条件的情况下,附加带有链接的单元格

      案例陈述可能是你最好的选择,而且它们更容易阅读,因为你没有复杂的 if elseif 条件。

      If e.Row.Cells(3).Text = "Y" Then 
      
          Select case Request("cid")
      
              case 15
                  e.Row.Cells(11).Text = "CID = 15 link " & e.Row.Cells(11).Text
              case 57
                  e.Row.Cells(11).Text = "CID = 57 link " & e.Row.Cells(11).Text
              case else
                  e.Row.Cells(11).Text = ""
          End Select
      
      End If
      

      【讨论】:

        猜你喜欢
        • 2021-10-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-09
        • 1970-01-01
        • 2020-05-22
        • 2023-02-21
        • 1970-01-01
        相关资源
        最近更新 更多