Hi. I have a DAL which works fine.

Then I put this line in my page somewhere

<asp:DropDownList ID="ddlDivision" DataSourceID="srcDivisions"
DataTextField="nomEn" DataValueField="ID" runat="server"></
asp:DropDownList>

My datasource is this one:
<asp:ObjectDataSource ID="srcDivisions" TypeName="DAL"
SelectMethod="getDivisions" OnObjectCreating="srcData_ObjectCreating"
CacheExpirationPolicy="Sliding" CacheDuration="300" runat="server"></
asp:ObjectDataSource>

it works great. My getDivisions method returns values from table
Divisions.

But actually I need to put this ddl inside my EditItemTemplate of a
grid, like so:

<asp:UpdatePanel ID="RefreshPanel" runat="server"
UpdateMode="Conditional">
  <ContentTemplate>
     <asp:GridView ID="grdWork" DataSourceID="srcWork"
AutoGenerateColumns="False" DataKeyNames="ID" ShowFooter="True"
runat="server">
.............................
<asp:TemplateField HeaderText="Division"  HeaderStyle-Width="15%" >

<EditItemTemplate>
   <asp:DropDownList ID="ddlDivision" DataSourceID="srcDivisions"
DataTextField="nomEn" DataValueField="ID" runat="server"></
asp:DropDownList>
</EditItemTemplate>
.................................


Whenever I hit the edit button in the grid, I get this error:

Microsoft JScript runtime error:
Sys.WebForms.PageRequestManagerServerErrorException: An error occurred
while executing the command definition. See the inner exception for
details.

which occurs in MicrosoftAjaxWebForms.debug.js on the code
_endPostBack: function PageRequestManager$_endPostBack(error,
executor, data) {
        if (this._request === executor.get_webRequest()) {
            this._processingRequest = false;
            this._additionalInput = null;
            this._request = null;
        }

        var eventArgs = new Sys.WebForms.EndRequestEventArgs(error,
data ? data.dataItems : {}, executor);
        Sys.Observer.raiseEvent(this, "endRequest", eventArgs);
        if (error && !eventArgs.get_errorHandled()) {
            throw error;
        }

If I stop the program here, the next time it will give me the error
"There is already an open DataReader associated with this Connection
which must be closed first."
Hmmmmm..... I'm using LINQ to entities. DataReader ? Maybe it's
internal. But anyway.


If I take out the line
<asp:DropDownList ID="ddlDivision" DataSourceID="srcDivisions"
DataTextField="nomEn" DataValueField="ID" runat="server"></
asp:DropDownList>
everything goes back to normal. I need to stress this: This line works
great when OUTSIDE the gridview ! It does not work inside it !

Please help ! Thank you very much !
Alex.

Reply via email to