开发者

Unable to cast object of type 'System.String' to type 'System.Web.UI.WebControls.Label'

I have a page that gets value from SQL. I'm having a problem when I initialize Label object with the field having TEXT data type.

Below is my code.

Dim csq As New Survey.DAL.CSurvey
csq.SurveyID = ViewState("SurveyId")
Dim dt As DataTable = csq.GetSurveyThankYouDetails
For Each r As DataRow In dt.Rows
    lblThankYoutext.text = r.Item("QuestionText") ' error falls here
    lbtLink.Text = r.Ite开发者_开发百科m("ThankYouLinkText")
Next


lblThankYou.Text perhaps (as opposed to lblThankYoutext)


lblThankYoutext.Text = r.Item("QuestionText") 


lblThankYoutext is a web control, use the .Text property of the label to assign it a value.

lblThankYoutext.Text = r.Item("QuestionText")


did you try

labelName.text =Convert.ToString( r.Item("QuestionText"))
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜