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"))
精彩评论