开发者

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

开发者 https://www.devze.com 2023-03-10 11:25 出处:网络
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.

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

精彩评论

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

关注公众号