Having an error: BC30311: Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.Label'.

Error Message:

Compiler Error Message: BC30311: Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.Label'.

Line 13: myGetRandom.RetrieveDetails(lblQuestion.text, lblAnswers.text, lblViewCount.text, lblLastUpdated.text)


Sub Page_Load
Dim myGetRandom as new GetRandom

myGetRandom.RetrieveDetails(lblQuestion.text, lblAnswers.text, lblViewCount.text, lblLastUpdated.text)

End Sub


Code behind

Sub RetrieveDetails(lblQuestion as label, _
lblAnswers as label, _
lblViewCount as label, _
lblLastUpdated as label)

Dim dtrQns as oleDBDataReader

'retrieving the Question ID
Dim intQnsID as integer = int32.parse(request.querystring("QID"))

'1. Create a connection
Dim strConnection as String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.Mappath("Data\rndQns.mdb")
Dim myConnection as New OleDBConnection(strConnection)
'2. Create the command object, passing in the SQL string
Dim strSQL as String = "SELECT * FROM QnAns WHERE QuestionID=@QnsID"
Dim myCommand as New OleDBCommand(strSQL, myConnection)
myCommand.Parameters.Add("@QnsID", intQnsID)

myConnection.open()
dtrQns = myCommand.ExecuteReader(commandBehavior.singleRow)

if dtrQns.read then

' Increment counter.
Dim intCount as integer

intCount = dtrQns("ViewCount") + 1

' Create a connection for the update
Dim myConnUpdate as New OleDBConnection(strConnection)
Dim strSQLUpdate as String = "UPDATE QnAns SET ViewCount=@Count WHERE QuestionID=@QnsID"
Dim myCmdUpdate as New OleDBCommand(strSQLUpdate, myConnUpdate)
myCmdUpdate.Parameters.Add("@Count", intCount)
myCmdUpdate.Parameters.Add("@QnsID", intQnsID)
myConnUpdate.open()
myCmdUpdate.executeNonQuery()
myConnUpdate.close()


' Displaying the records in label tags
lblQuestion.text = dtrQns("Question")
lblAnswers.text = dtrQns("Answers")
lblViewCount.text = intCount
lblLastUpdated.text = dtrQns("LastUpdated")

end if

dtrQns.close()
myConnection.close()

End Sub

Can anyone tell me what is wrong? I am totally lost
0
pyroxz
10/21/2004 4:16:09 PM
asp.net.getting-started 91979 articles. 2 followers. Follow

2 Replies
613 Views

Similar Articles

[PageSpeed] 30

You cannot do something like this: 

 

Sub RetrieveDetails(lblQuestion as label, _
lblAnswers as label, _
lblViewCount as label, _
lblLastUpdated as label)

instead of the above if you really want to assign the text to the label you can do something like this:
 

Sub RetrieveDetails(lblQuestion as String, _
lblAnswers as String, _
lblViewCount as String, _
lblLastUpdated as String)

And later assign the values to the Label.Text:


HighOnCoding
Wanna get high!
0
azamsharp
10/21/2004 4:44:15 PM
looks like you're passing in the text value, but in your sub definition, you are saying you will pass in the actual label, so i think if you pass in the label instead of the .text value, it should work like you want it, like this:


myGetRandom.RetrieveDetails(lblQuestion, lblAnswers, lblViewCount, lblLastUpdated)

hope that helps,
-Mike
0
effervescent
10/21/2004 4:47:38 PM
Reply:

Similar Artilces:

BC30311: Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.Label'.
I have a pretty basic vb.net page that includes a listview.  (Note, this is my first time working with listview, so I may have some of the terminology wrong).  In my list view, I display all the important data for each record, and ask the user to provide a status for each record by including a radiobutton list with various responses.  At the bottom of the page is one submit button, and when the user clicks submit, I'm saving each records value based upon which response is selected in the radiobutton list. My saving of data is working,  but I'm ...

Error: Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.Label
Here is the code:Dim dato_start_2 as DateTime Dim varighet_str as string Dim dato_differanse as string dato_start_2 = tabell_2.Rows(DataGrid1.SelectedIndex).Item("dato_tid_sendt") dato_differanse = DateDiff(DateInterval.Day, dato_start_2, now) Label12 = "" & dato_differanse & ""  ........and theCompiler Error Message: BC30311: Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.Label'.Why and how?RegardsLars/Norway To set a text for a Label you need to use its Text property, in your code you try to set the Label to a Text and that is the reason why you g...

BC30311: Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.TextBox'.
 Hello everyone, I receive the error in the subject when viewing this page, I can get it to work fine without the master page and only the textboxes, but that causes an error with line 11, even when the page contents do process to the form. I don`t understand the error and I would appreciate any guidance on this. Thanks for reading.1 <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %> 2 3 <script runat="server"> 4 5 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) 6 Dim D...

BC30311: Value of type 'System.Web.UI.WebControls.RadioButtonList' cannot be converted to 'String'.
I have a listview that I'm working with.  Each record returned by my sql query is displayed in my list view as text, with the exception of one field, which I need to display as a radiobutton list.  I tried to set the value of the radiobutton in my codebehind, but keep getting errors.  How do I tell this radiobutton list that the value that should be selected when the page loads is equal to the value returned from my sql query?    The line in bold throws the error... How am I supposed to indicate what value to have selected when the page loads? <asp:Radi...

Error Serializing Value 'System.Web.UI.WebCOntrols.TreeNode' of type 'System.Web.UI.WebCOntrols.TreeNode'
Hi, I am  getting the error stated in the subject when i am storing a TreeNode in a ViewState and then using it as follows if (ViewState["ProductCounty"]!=null) { TreeNode _productCountyNode = DataTree.FindNode(((TreeNode)ViewState["ProductCounty"]).ValuePath); _productCountyNode.Expand(); } what could be causing this error? Hi, I believe TreeNode isn't serializable in a way its required for objects which can be put to ViewState - as reference - (TreeNode implements IStateManager and is meant to work together with TreeView itself saving it...

Error: Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField'
Hello, I am getting the following error during compiliation. Any suggestions to fix it. Thanks. Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField' protected void gvEvents_RowCommand(Object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gvEvents.Rows[index]; string sID; ButtonField btn; if (selectedRow.RowType == DataControlRowType.DataRow) { sID = ((ButtonField)selectedRow.FindControl("ID")).DataTextFi...

Cannot implicitly convert type 'System.Web.UI.WebControls.Label' to 'string'
I have a datagridLabel ID1 = (Label)(e.Item.FindControl("ID1")); Label Name1 = (Label)(e.Item.FindControl("Name1")); Label TableName = (Label)(e.Item.FindControl("TableName"));   No0w Iam trying to TBTableName.Text = lblTableName;                  tbid.Text = lblImageTypeID1;                   tbnameordes.Text = lblImageName1; I have tried l lbltablename.text,.tostring,convert.t...

Cannot implicitely convert type 'string' to 'System.Web.UI.WebControls.Label'
 I'm starting to make a website for users to login. Once they login, I'm showing their profile. So I populate some asp:label controls on Page_Load. My profile page (shown after the user logs in) contains: <%@ Page Language="C#" MasterPageFile="~/site.master" CodeFile="clientProfile.aspx.cs" Inherits="clientProfile" AutoEventWireup="true" Title="Car Look - Your profile" %> <asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server"> <div> &l...

Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.TextBox'
I have a new page (wireframe) based on the User_Create page in the Time Tracker starter kit.  I have no code in the code behind page.  What might be causing this error?  This newbie needs help. I had a TextBox control named "Title" which appearantly conflicted with the page title. thanks!!! ...

Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TextBox'
I am attempting to "Update" a field in a Datagrid, but no matter what I do (Using either Label or Text Boxes)  I keep getting the same error: Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TextBox' The Error is highlighted below in the Sub... <==THE FIELD THAT CALLS THE ERROR  Any help would be greatly appreciated !!! Thanks !!   The code is as follows... <table border=0 height=210 bordercolor=olive ><tr valign=top><td> <asp:datagrid id="FacilityDataGrid"...

BC30311: Value of type 'Control' cannot be converted to 'System.Web.UI.WebControls.CheckBox'
 Hi, can somebody help me on this problem. It works at first, but all of a sudden, it fails, and I can't find out why.    1 Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) 2 3 If Not CheckRequiredField() Then 4 MessageBox("Please complete the input data!") 5 Exit Sub 6 End If 7 8 Dim nRow As Integer 9 Dim Ctrl As Control 10 Dim chkDelete As Object 11 Dim LookupID, Name, Desc, Type As String 12 13 nRow = 0 14 1...

Cannot implicitly convert type 'System.Web.UI.WebControls.Label' to 'string' #2
Hi i am getting the following error "Cannot implicitly convert type 'System.Web.UI.WebControls.Label' to 'string'", what am i doing wrong, my code looks like this;protected void lbtnSubmit_Click(object sender, EventArgs e) {foreach(DataGridItem dgi in dgAvailability.Items) {AvailabilityBLC availabilityBLC = new AvailabilityBLC(); availabilityBLC.Availability.AvailabilityDay =(Label)dgi.FindControl("lblDay");availabilityBLC.Availability.AvailabilityPrice = (TextBox)dgi.FindControl("priceTxt"); availabilityBLC.Availability.BBooked = (CheckB...

Error 60 Operator '&' is not defined for types 'System.Web.UI.WebControls.TextBox' and 'String'.
The comment control is a textbox:<td align="right" style="width: 228px"><asp:TextBox ID="comment" runat="server" TextMode="multiLine" Rows="10" Columns="50" onkeyup="return ismaxlength(this)" Width="260px" Height="100px" Font-Overline="false" /></td> and I'm being told by VS (underlined in blue ) that the for the comment field: Error 60 Operator '&' is not defined for types 'System.Web.UI.WebControls.TextBox' and 'String...

Compiler Error Message: BC30311: Value of type 'System.Web.UI.DataSourceSelectArguments' cannot be converted to 'Integer'.
 Hello, I'm wondering if someone can help me figure out why I'm receiving the above error message..."Compiler Error Message: BC30311: Value of type 'System.Web.UI.DataSourceSelectArguments' cannot be converted to 'Integer'." In visual web developer, the blue line is pointing out the variables args, on line 15.   1 Imports System.Data 2 Partial Class POS_so_Default 3 Inherits System.Web.UI.Page 4 5 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 6 customer...

Web resources about - Having an error: BC30311: Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.Label'. - asp.net.getting-started

Resources last updated: 12/24/2015 2:01:37 AM