Bonjour,

J'ai un pb que je n'arrive pas à comprendre. Lorsque je suis en mode édition sur une ligne de ma DataGrid, je peux cliquez sur Annuler ce qui déclenche l'événement "DataGrid1_Cancel".
Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
protected void DataGrid1_Cancel(object sender, DataGridCommandEventArgs e){
Response.Write("Je passe par là !");
DataGrid1.EditItemIndex=-1; <-- La ligne qui pose problème !!!
DataGrid1Bind();
}
Mon problème est apparue quand j'ai ajouté la deuxième ligne. A l'initialisation de ma DataGrid, j'ai le message suivant :
Server Error in '/' Application.
--------------------------------------------------------------------------------

The IListSource does not contain any data sources.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The IListSource does not contain any data sources.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): The IListSource does not contain any data sources.]
System.Web.UI.DataSourceHelper.GetResolvedDataSource(Object dataSource, String dataMember) +361
System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean useDataSource) +472
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +48
System.Web.UI.WebControls.BaseDataList.DataBind() +10
WebRAMSES.claImportFichierMapping.DataGrid1_Cancel(Object sender, DataGridCommandEventArgs e) +88
System.Web.UI.WebControls.DataGrid.OnCancelCommand(DataGridCommandEventArgs e) +84
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +540
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +101
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +95
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +116
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1258




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
Si je la mets en commentaire, pas de plantage. Mais mon Response.Write n'apparait pas à l'initialisation. Il n'apparait que quand je clique sur Annuler en mode édition.
Alors je ne comprends pas trop...