ASP.NET - asp - Asked By Rohini Kuchadi on 11-Nov-11 07:13 AM

Error    1    'ASP.ratehistory_aspx' does not contain a definition for 'DataList1_ItemCommand' and no extension method 'DataList1_ItemCommand' accepting a first argument of type 'ASP.ratehistory_aspx' could be found (are you missing a using directive or an assembly reference?)    C:\Documents and Settings\Administrator\My Documents\Desktop\rohini\itransi1\ratehistory.aspx    1    1    C:\...\itransi1\


Can i know why am getting this error. And how can i slove it. Whete can i get that DataList1_ItemCommand  event.
dipa ahuja replied to Rohini Kuchadi on 11-Nov-11 07:19 AM
Its coming because you have not added the DataListItemCommand event in the codebehind and define it in the markup page

solution :

<asp:DataList ID="DataList1" runat="server" OnItemCommand="DataList1_ItemCommand">

code behind:

protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
  //code
}

Suchit shah replied to Rohini Kuchadi on 11-Nov-11 07:26 AM
This error is Coming of because in your ASPX page you have defined 'DataList1_ItemCommand' Event and in your code behind file you dont have right the Defination of that File .. .So in this case you can do 2 things
1. Remove that Event from ASPX page
2. Add that Method Defination with proper Argument in your Code Behind file


Kirtan Patel replied to Rohini Kuchadi on 11-Nov-11 07:29 AM
just remove that  DataList1_ItemCommand attribute from the HTML markup and error will not be there .its coming because you dont have handler method in your cs file Thanks
Rohini Kuchadi replied to dipa ahuja on 11-Nov-11 07:35 AM
How can i add it in the codebehind file.  

in design page. in a table, i have datalist and itemcommand like this.

</ItemCommand>   </asp:DataList>
dipa ahuja replied to Rohini Kuchadi on 11-Nov-11 07:44 AM
ItemCommand is an event, and there is no such tag <ItemCommand>

if you want to implement this event then first remove the ItemCommand property from the <DataList ... > tag

then go to the design view: Go to the DataList Event and double Click on the ItemCommand