CS1040: Preprocessor directives must appear as the first non-white

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a check box in a column of my DataGrid. This DataGrid lists all the
users of my site and the CheckBox basically is for me to toggle between
disabling or enabling a user.

This is the code for the CheckBox.

<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id="ChkBoxDisable" runat="server" Checked='<%#
DataBinder.Eval(Container.DataItem, "disable") %>' AutoPostBack="True"
OnCheckedChanged='DisableClicked(<%# DataBinder.Eval(Container.DataItem,
"userID") + "," + DataBinder.Eval(Container.DataItem, "disable") %>)' />
</ItemTemplate>
</asp:TemplateColumn>

I wanted it to call the method DisableClicked(int userID, int currentStatus)
when it's clicked. However, it's giving me a compiler error:

CS1040: Preprocessor directives must appear as the first non-whitespace
character on a line

What's wrong?

Thanks.
 
Instead of

'DisableClicked(<%# DataBinder.Eval(Container.DataItem,
"userID") + "," + DataBinder.Eval(Container.DataItem, "disable") %>)'

DisableClicked('<%# DataBinder.Eval(Container.DataItem,
"userID") + "," + DataBinder.Eval(Container.DataItem, "disable") %>')

It must have been the single-quote that must be throwing the exception.

with regards,

J.V.
 
Hi J.V.,

Now it gives "The server tag is not well formed." on the line:

<asp:CheckBox id="ChkBoxDisable" runat="server"
Checked='<%# DataBinder.Eval(Container.DataItem, "disable") %>'
AutoPostBack="True"
OnCheckedChanged=DisableClicked('<%# DataBinder.Eval(Container.DataItem,
"userID") + "," + DataBinder.Eval(Container.DataItem, "disable") %>') />


WB.
 
Back
Top