I am binding the DataSet with WebDataGrid as DataSource. While adding row I am facing the Exception as follows
[Exception] :Original data source does not support inserts.
So how can I not allow to insert the row to DataSet. And I want to add row explicitly from RowAdding Event.
So how can I do that without facing Exception?
ok , i am writing the answer what i understood ,
DataKeyFields="HSE_id" EnableDataViewState="True" EnableViewState="True"
ADD THSE LINES AS BELOW AND TRY IT ,IF Ur's problem solved it's good
<ig:WebDataGrid ID="wdg" runat="server" Height="350px" Width="99%" DataKeyFields="HSE_id" EnableDataViewState="True" EnableViewState="True" >
Hello:
I changed my code to use ICollection interface and the error went away
protected
void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
this.WebDataGrid1.DataSource = this.GetDataSource();
this
.WebDataGrid1.DataBind();
}
private ICollection GetDataSource()
ICollection dataSource = null;
dataSource = GetGTINDataSource();
return
dataSource;
Thank you,
Sushma
Hi, Thanks for your answer.
I have of course DatakeyFileds set. To explain you how it works anormaly : When i stop my application and re open it, it works : i can add my row normally and all other rows i want to add.
I think it has relation with CacheDuration. I don't know how to use it!
here is an extract of my aspx contaning the definition of maWebDatagrid and bounded database.
<ig:WebDataGrid ID="grdInscriptions" runat="server" AutoGenerateColumns="False" AutoCRUD="true" DataSourceID="InscriptionsQry" DataKeyFields ="ID_FORMATEUR,ID_SESSION,ID_STAGIAIRE" Font-Size="XX-Small" Height="220px" Width="855px" onrowadding="grdInscriptions_RowAdding" onrowselectionchanged="grdInscriptions_RowSelectionChanged" onrowupdating="grdInscriptions_RowUpdating" ViewStateMode="Enabled"> <Columns> <ig:TemplateDataField Key="DeleteItem" Width="20px"> <ItemTemplate> <asp:ImageButton runat="server" ID="DeleteItem" AlternateText="Delete" ImageUrl="~/Images/CorporateGold/del_hover.gif" OnClientClick="DeleteSub(); return false;" CausesValidation="True" /> </ItemTemplate> </ig:TemplateDataField>
<ig:BoundDataField DataFieldName="ID_FORMATEUR" Key="ID_FORMATEUR" Hidden="false" DataType="System.Int16"> <Header Text="ID_Formateur" /> </ig:BoundDataField>
<ig:BoundDataField DataFieldName="ID_SESSION" Key="ID_SESSION" Hidden="false" DataType="System.String"> <Header Text="ID_Session" /> </ig:BoundDataField>
<ig:BoundDataField DataFieldName="ID_STAGIAIRE" key="ID_STAGIAIRE" Width="100px" DataType="System.String" > <Header Text="n° SS" CssClass="header"/> </ig:BoundDataField>
<ig:BoundDataField DataFieldName="Stagiaire" Key="Stagiaire" Width="130px" DataType="System.String"> <Header Text="Stagiaire" CssClass="header"/> </ig:BoundDataField>
<ig:BoundDataField DataFieldName="ID_FORMATION_DETAIL" Key="ID_FORMATION_DETAIL" Hidden="false" DataType="System.Int16"> <Header Text="ID_FORMATION_DETAIL" CssClass="header"/> </ig:BoundDataField>
<ig:BoundDataField DataFieldName="INTITULE" Key="INTITULE" Width="220px" DataType="System.String"> <Header Text="Formation" CssClass="header"/> </ig:BoundDataField>
<ig:BoundDataField DataFieldName="DATE_DEBUT" Key="DATE_DEBUT" Width="75px" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy H:mm}"> <Header Text="de" CssClass="header"/> </ig:BoundDataField>
<ig:BoundDataField DataFieldName="DATE_FIN" Key="DATE_FIN" Width="75px" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy H:mm}"> <Header Text="à" CssClass="header"/> </ig:BoundDataField>
<ig:TemplateDataField Key="Duration" Width="70px"> <ItemTemplate> <asp:Label ID="txtDuration" runat="server"> </asp:Label> </ItemTemplate> <Header Text="Durée" CssClass="header"/> </ig:TemplateDataField> </Columns> <EditorProviders> <ig:DropDownProvider ID="drpStagiairesNonInscrits"> <EditorControl ID="drpStagiairesProvider" runat="server" DataSourceID="ds_StagiairesNonInscrits" DisplayMode="DropDownList" TextField="Stagiaire" ValueField="ID_STAGIAIRE"> <DropDownItemBinding TextField="Stagiaire" ValueField="ID_STAGIAIRE" /> <ClientEvents ValueChanged="grdInscriptions_DropDown_ValueChanged" /> </EditorControl> </ig:DropDownProvider> <ig:DropDownProvider ID="drpFormations"> <EditorControl ID="drpFormationsProvider" runat="server" DataSourceID="ds_FormationsQry" DisplayMode="DropDownList" TextField="INTITULE" ValueField="ID_FORMATION_DETAIL"> <DropDownItemBinding TextField="INTITULE" ValueField="ID_FORMATION_DETAIL" /> <ClientEvents ValueChanged="grdInscriptions_DropDown_ValueChanged" /> </EditorControl> </ig:DropDownProvider> <ig:DatePickerProvider ID="DateInputProvider"> <EditorControl ID="datesStagesProvider" runat="server" Culture="en-US" DisplayModeFormat="MM/dd/yyyy H:mm" Fields="2010-12-6-0-0-0-0" EditModeFormat="MM/dd/yyyy H:mm" DataMode="DateOrNull" Font-Bold="True"> </EditorControl> </ig:DatePickerProvider> </EditorProviders> <Behaviors> <ig:RowSelectors Enabled="true" RowNumbering="true" > <RowSelectorClientEvents RowSelectorClicked="grdInscriptions_RowSelector_RowSelectorClicked" /> </ig:RowSelectors>
<ig:Selection RowSelectType="Single" EnableCrossPageSelection="True"> <SelectionClientEvents RowSelectionChanged="onRowSelectionChanged" /> <AutoPostBackFlags RowSelectionChanged="True" /> </ig:Selection> <ig:Activation> </ig:Activation>
<ig:EditingCore> <EditingClientEvents RowAdding="grdInscriptions_Editing_RowAdding" /> <Behaviors> <ig:RowAdding Alignment="Top" EditModeActions-EnableOnActive="true" EditModeActions-MouseClick="Single" Enabled="true"> <AddNewRowClientEvents Initialize="grdInscriptions_RowAdding_Initialize" ExitedEditMode="grdInscriptions_RowAdding_ExitedEditMode" /> <EditModeActions EnableOnActive="True" MouseClick="Single" /> <ColumnSettings> <ig:RowAddingColumnSetting ColumnKey="ID_FORMATEUR" /> <ig:RowAddingColumnSetting ColumnKey="ID_SESSION" /> <ig:RowAddingColumnSetting ColumnKey="ID_STAGIAIRE" ReadOnly="true"/> <ig:RowAddingColumnSetting ColumnKey="Stagiaire" EditorID = "drpStagiairesNonInscrits" /> <ig:RowAddingColumnSetting ColumnKey = "ID_FORMATION_DETAIL" EditorID ="drpFormations" /> <ig:RowAddingColumnSetting ColumnKey = "INTITULE" EditorID ="drpFormations"/> <ig:RowAddingColumnSetting ColumnKey ="DATE_DEBUT" EditorID="DateInputProvider"/> <ig:RowAddingColumnSetting ColumnKey ="DATE_FIN" EditorID="DateInputProvider"/> </ColumnSettings> </ig:RowAdding>
<ig:CellEditing Enabled="true"> <ColumnSettings> <ig:EditingColumnSetting ColumnKey ="ID_FORMATEUR" /> <ig:EditingColumnSetting ColumnKey ="ID_SESSION" /> <ig:EditingColumnSetting ColumnKey="ID_STAGIAIRE" ReadOnly="true"/> <ig:EditingColumnSetting ColumnKey ="Stagiaire" EditorID = "drpStagiairesNonInscrits" ReadOnly="true"/> <ig:EditingColumnSetting ColumnKey ="ID_FORMATION_DETAIL" EditorID ="drpFormations" /> <ig:EditingColumnSetting ColumnKey = "INTITULE" EditorID ="drpFormations"/> <ig:EditingColumnSetting ColumnKey ="DATE_DEBUT" EditorID="DateInputProvider"/> <ig:EditingColumnSetting ColumnKey ="DATE_FIN" EditorID="DateInputProvider"/> </ColumnSettings> <CellEditingClientEvents ExitedEditMode="grdInscriptions_CellEditing_ExitedEditMode" /> </ig:CellEditing>
<ig:RowDeleting Enabled="true" /> </Behaviors> </ig:EditingCore> </Behaviors> </ig:WebDataGrid> <asp:SqlDataSource ID="InscriptionsQry" runat="server" EnableCaching ="True" ConnectionString="<%$ ConnectionStrings:procaConn %>" SelectCommand = "SELECT s.ID_STAGIAIRE, i.ID_FORMATEUR, i.ID_SESSION, s.CIVILITE + ' ' + s.NOM + ' ' + s.PRENOM AS Stagiaire, i.ID_FORMATION_DETAIL, fd.INTITULE, i.DATE_DEBUT, i.DATE_FIN FROM STAGIAIRE AS s INNER JOIN INSCRIPTION AS i ON s.ID_STAGIAIRE = i.ID_STAGIAIRE LEFT OUTER JOIN FORMATION_DETAILS AS fd ON fd.ID_FORMATION_DETAIL = i.ID_FORMATION_DETAIL Where i.ID_SESSION = @ID_SESSION And s.ID_STAGIAIRE <> 'noname'" InsertCommand = "Insert Into INSCRIPTION (ID_FORMATEUR, ID_SESSION, ID_STAGIAIRE, ID_FORMATION_DETAIL, DATE_DEBUT, DATE_FIN) Values(@ID_FORMATEUR, @ID_SESSION, @ID_STAGIAIRE, @ID_FORMATION_DETAIL, @DATE_DEBUT, @DATE_FIN)" DeleteCommand ="Delete From INSCRIPTION Where ID_FORMATEUR = @ID_FORMATEUR And ID_SESSION = @ID_SESSION And ID_STAGIAIRE = @ID_STAGIAIRE" UpdateCommand ="Update INSCRIPTION Set ID_FORMATION_DETAIL = @ID_FORMATION_DETAIL, DATE_DEBUT = @DATE_DEBUT, DATE_FIN = @DATE_FIN Where ID_FORMATEUR = @ID_FORMATEUR And ID_SESSION = @ID_SESSION And ID_STAGIAIRE = @ID_STAGIAIRE" CacheDuration="1" ViewStateMode="Enabled" > <InsertParameters> <asp:Parameter Name="ID_FORMATEUR" Type="Int16" /> <asp:Parameter Name="ID_SESSION" Type="String" /> <asp:Parameter Name="ID_STAGIAIRE" Type="String" /> <asp:Parameter Name="ID_FORMATION_DETAIL" Type="Int16" /> <asp:Parameter Name="DATE_DEBUT" Type="DateTime" /> <asp:Parameter Name="DATE_FIN" Type="DateTime" /> </InsertParameters> <SelectParameters> <asp:ControlParameter Name="ID_SESSION" ControlID="drpSession" PropertyName="SelectedValue" Type="String" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="ID_FORMATEUR" Type="Int16" /> <asp:Parameter Name="ID_SESSION" Type="String" /> <asp:Parameter Name="ID_STAGIAIRE" Type="String" /> <asp:Parameter Name="ID_FORMATION_DETAIL" Type="Int16" /> <asp:Parameter Name="DATE_DEBUT" Type="DateTime" /> <asp:Parameter Name="DATE_FIN" Type="DateTime" /> </UpdateParameters>
<DeleteParameters> <asp:Parameter Name="ID_FORMATEUR" Type ="Int16" /> <asp:Parameter Name="ID_SESSION" Type="String" /> <asp:Parameter Name="ID_STAGIAIRE" Type="String" /> </DeleteParameters>
</asp:SqlDataSource>
Hi,
Is your DataKEyFields set? Can you upload your aspx? It shouldn't be too hard to figure this out with some code.
Ed
Hello,
I have this problem too and it is aleatoire!!!
I have an insert command and my datasource is not readonly!!!
Can some one help me to solve this.
Best regards