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

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.
 
G

Guest

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top