开发者

radiobuttonlist value with regex error

I'm trying to remove any html tags, mainly from the value piece of a radiobuttonlist item. Without the regex, it works, but causes other errors. Here's what I have, but the error it gives is: Object re开发者_StackOverflow社区ference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. rad.DataValueField = myStr.stripHTML(ds.Tables("session_name").ToString) Any advice appreciated.

Here's my code:

  Dim rad As RadioButtonList = New RadioButtonList()
  rad.ID = "rad" + i.ToString()
  rad.DataSource = ds.Tables("conSessions")
  rad.DataTextField = ds.Tables("conSessions").Columns("session_name").ToString
  rad.DataValueField = myStr.stripHTML(ds.Tables("session_name").ToString)
  rad.DataBind()
  rad.DataBind()
  rad.SelectedIndex = 0
  phConcurrent.Controls.Add(rad)

Public Function stripHTML(ByVal e As String) As String
    If (e = String.Empty) Or (IsDBNull(e) = True) Then
       Return ""
    Else
       Return System.Text.RegularExpressions.Regex.Replace(e, "<[^>]*>", "", RegexOptions.IgnoreCase Or RegexOptions.Multiline)
    End If
End Function


I suppose the problem is not in regex. Possibly you're trying to get wrong table here:

ds.Tables("session_name").ToString

Are you sure that you need table with this name and not with name "conSessions" ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜