Voici un morceau de code pour vous aider à utiliser l’événement Command d’un Datalist
private void MyDataList_ItemCommand(Object sender, DataListCommandEventArgs E)
{
String title = MyDataList.DataKeys[E.Item.ItemIndex].ToString();
String command = E.CommandName;
switch(command)
{
case "Discuss" :
ShowDiscussions(title);
break;
case "Ratings" :
ShowRatings(title);
break;
}
}
void ShowRatings(String title)
{
Message.InnerHtml = " Ratings for \"" + title + "\"";
Message.InnerHtml += "Print Ratings here…";
}
void ShowDiscussions(String title)
{
Message.InnerHtml = " Discussions for \"" + title + "\"";
Message.InnerHtml += "Print Discussions here…";
}