Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 672
  • Last Modified:

Datalist error: Identifier expected, 'as' is a keyword

Here's the full error I get loading a Datalist:

Compiler Error Message: CS1041: Identifier expected, 'as' is a keyword

Source Error:

 

Line 33: }
Line 34:
Line 35: void DataList1_ItemCommand(Sender as object, e as DataListCommandEventArgs      <-----------------

Here's my code:

void DataList1_ItemCommand(Sender as object, e as DataListCommandEventArgs) {
      DataList1.SelectedIndex = e.Item.ItemIndex;
      DataList1.DataBind();
}





TIA,

Dinesh


 
0
dprasad
Asked:
dprasad
  • 2
1 Solution
 
ihenryCommented:
Hello dprasad

Do you use c# or vb.net?

in c# there's no "as datatype" in parameter declaration, use this declaration instead

void DataList1_ItemCommand(Sender object, DataListCommandEventArgs e) {
      DataList1.SelectedIndex = e.Item.ItemIndex;
      DataList1.DataBind();
}
0
 
ihenryCommented:
Sorry forgot something, it should be

void DataList1_ItemCommand(object Sender, DataListCommandEventArgs e) {
      DataList1.SelectedIndex = e.Item.ItemIndex;
      DataList1.DataBind();
}
0
 
dprasadAuthor Commented:
Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now