BC30201: Expression expected. [modified]
-
Hello All I've a grid with multiple columns ,one of them is a boolean column,i want to represent it as a chackbox , when the checkbox checked or unckecked i want the database to change automatically , i get this error before the page even loaded ,here is the Source Error: ------------------------------------------------------------------- Line 38: Line 39: Line 42: ------------------------------------------------------------------------ Microsoft (R) Visual Basic Compiler version 8.0.50727.42 for Microsoft (R) .NET Framework version 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. C:\CRFF\Default.aspx.vb(79) : warning BC42104: Variable 'wks' is used before it has been assigned a value. A null reference exception could result at runtime. If Not (wks Is Nothing) Then ~~~ C:\CRFF\Default2.aspx(49) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed. Dim s = r("employeeid").ToString ~ C:\CRFF\IT_Daily_Tasks.aspx(40) : error BC30201: Expression expected. target.SetDataBoundString(1, System.Convert.ToString(Container.Value == "True" ? "checked='checked'" : "", System.Globalization.CultureInfo.CurrentCulture)) ~ C:\CRFF\IT_Daily_Tasks.aspx(40) : error BC30035: Syntax error. target.SetDataBoundString(1, System.Convert.ToString(Container.Value == "True" ? "checked='checked'" : "", System.Globalization.CultureInfo.CurrentCulture)) ---------------------------------------------------------------------------- Help Please
modified on Wednesday, December 2, 2009 12:10 AM
Try the following:
<asp:CheckBox ID="chkBox" runat="server" önclick="updateSent(this.checked, <%# Container.PageRecordIndex %>)" Checked='<%# Container.Value == "True" ? "true" : "false" %>' />
Hope that this will work.
Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.
-
Try the following:
<asp:CheckBox ID="chkBox" runat="server" önclick="updateSent(this.checked, <%# Container.PageRecordIndex %>)" Checked='<%# Container.Value == "True" ? "true" : "false" %>' />
Hope that this will work.
Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.
-
I understand that your code behind is VB.NET [C:\CRFF\Default.aspx.vb]. As far as I know there is no ternary operator i.e. [expr?expr:expr], available in VB.
Actually i do have VB.net code behind ,but for the purpose of instant DB updating i've used JAVASCRIPT the sript is below, hope that would clarify function updateSent(bSent, iRowIndex) { var oRecord = new Object(); oRecord.OrderID = grid1.Rows[iRowIndex].Cells[0].Value; oRecord.ShipName = grid1.Rows[iRowIndex].Cells[1].Value; oRecord.ShipCity = grid1.Rows[iRowIndex].Cells[2].Value; oRecord.ShipPostalCode = grid1.Rows[iRowIndex].Cells[3].Value; oRecord.ShipCountry = grid1.Rows[iRowIndex].Cells[4].Value; oRecord.Sent = bSent; grid1.executeUpdate(oRecord); }
-
Actually i do have VB.net code behind ,but for the purpose of instant DB updating i've used JAVASCRIPT the sript is below, hope that would clarify function updateSent(bSent, iRowIndex) { var oRecord = new Object(); oRecord.OrderID = grid1.Rows[iRowIndex].Cells[0].Value; oRecord.ShipName = grid1.Rows[iRowIndex].Cells[1].Value; oRecord.ShipCity = grid1.Rows[iRowIndex].Cells[2].Value; oRecord.ShipPostalCode = grid1.Rows[iRowIndex].Cells[3].Value; oRecord.ShipCountry = grid1.Rows[iRowIndex].Cells[4].Value; oRecord.Sent = bSent; grid1.executeUpdate(oRecord); }
Based on your question I understood that we are talking about a compilation error and my comment was about the checkbox definition statement
/>
You are using a server evaluation to set the checked status using the ternary operator in the below line.
<%# Container.Value == "True" ? "checked='checked'" : "" %>
I guess this is where the error is, using ternary operator in a server evaluation where the code behind is VB.NET -
Hello All I've a grid with multiple columns ,one of them is a boolean column,i want to represent it as a chackbox , when the checkbox checked or unckecked i want the database to change automatically , i get this error before the page even loaded ,here is the Source Error: ------------------------------------------------------------------- Line 38: Line 39: Line 42: ------------------------------------------------------------------------ Microsoft (R) Visual Basic Compiler version 8.0.50727.42 for Microsoft (R) .NET Framework version 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. C:\CRFF\Default.aspx.vb(79) : warning BC42104: Variable 'wks' is used before it has been assigned a value. A null reference exception could result at runtime. If Not (wks Is Nothing) Then ~~~ C:\CRFF\Default2.aspx(49) : warning BC42020: Variable declaration without an 'As' clause; type of Object assumed. Dim s = r("employeeid").ToString ~ C:\CRFF\IT_Daily_Tasks.aspx(40) : error BC30201: Expression expected. target.SetDataBoundString(1, System.Convert.ToString(Container.Value == "True" ? "checked='checked'" : "", System.Globalization.CultureInfo.CurrentCulture)) ~ C:\CRFF\IT_Daily_Tasks.aspx(40) : error BC30035: Syntax error. target.SetDataBoundString(1, System.Convert.ToString(Container.Value == "True" ? "checked='checked'" : "", System.Globalization.CultureInfo.CurrentCulture)) ---------------------------------------------------------------------------- Help Please
modified on Wednesday, December 2, 2009 12:10 AM
Why din't I think of this before? Ok try this!
" />
-
Based on your question I understood that we are talking about a compilation error and my comment was about the checkbox definition statement
/>
You are using a server evaluation to set the checked status using the ternary operator in the below line.
<%# Container.Value == "True" ? "checked='checked'" : "" %>
I guess this is where the error is, using ternary operator in a server evaluation where the code behind is VB.NET -
I guess you are right ,cuz when i removed the[evaluation] the page loaded succesfuly , now do i have to give up the whole idea of changing the DB instantly via some JavaScript code?
Did you try using the IFF function to evaluate the checked status?
-
Why din't I think of this before? Ok try this!
" />
-
Did you try using the IFF function to evaluate the checked status?
-
Thnx Sir,i tried but i got: BC30451: Name 'IFF' is not declared. i tried : Checked="<%# IF((Container.Value = "True"), true, false)%>" /> i got the old error : BC30201: Expression expected.
alaminfad wrote:
i tried : Checked="<%# IF((Container.Value = "True"), true, false)%>" />
mm, try this -
Checked="<%# IF(Container.Value = "True") Then True Else False)%>"