ReorderList InsertItem not sending in value to sortorderfield

Last post 05-06-2009 11:34 PM by Zhi-Qiang Ni - MSFT. 2 replies.

Sort Posts:

  • ReorderList InsertItem not sending in value to sortorderfield

    04-30-2009, 4:21 PM
    • Member
      point Member
    • trentmas
    • Member since 04-30-2009, 7:15 PM
    • Posts 2

    Hope someone can help me with this oddity. I'm fairly new to the reorderlist control and have implemented one using the standard newbie method- watch the asp.net video and create one by dragging and dropping controls- including sticking all sql database connection and statement information straight into the aspx page. (ooff I hate doing this).

    For some reason I am not able to add new items to the reorderlist (using the iteminserttemplate) and get the error: PageRequestManagerServerErrorException: Cannot insert the value NULL into column 'display_order', table databasename.dbo.tablename, column does not allow nulls.

    The control is hooked to a table that has a 'display_order' column (int, not null). I have defined sortorderfield="display_order". As far as other reorderlists that I have working fine on other pages that also use tables with display_order columns, the display_order always seems to have it's value assigned automagically- I never assign it explicitly upon submitting new items, yet the display_order column for tables that support those other pages always have a value sent in correctly (I have profiled the SQL data) and see the parameter have an assigned value. If it's the first row added it gets a zero, otherwise it passes in a number one greater than the greatest current display_order value.

    Can someone tell me how ASP.Net knows (or in this one instance doesn't know) how to automatically assign the integer sqlparameter for the column defined by sortorderfield? Better yet, can you tell me what I am doing wrong? Here's the code:

     <cc1:reorderlist id="rolTestCase" runat="server"
         allowreorder="True"
         postbackonreorder="False"
         iteminsertlocation="End"
         datakeyfield="test_case_id" sortorderfield="display_order"
         width="100%"
         showinsertitem="True"
         cssclass="reorder"
         datasourceid="dsTest">

    ---drag,reorder,edit templates removed----

    <insertitemtemplate>
    <span>
    <asp:panel id="pnlInsertItem" runat="server" defaultbutton="btnInsertItem">
          <asp:textbox id="txtInsertItem" runat="server" text='<%# Bind("test_case_name") %>' />
          <asp:button id="btnInsertItem" runat="server" commandname="Insert" text="Add Test Case" />
    </asp:panel>
    </span>
    </insertitemtemplate>
    </cc1:reorderlist>

    <asp:sqldatasource id="dsTest" runat="server" connectionstring="<%$ ConnectionStrings:MyConnectionString %>"  insertcommand="INSERT INTO [test_case] ([test_case_name], [display_order], [test_module_id]) VALUES (@test_case_name, @display_order, @test_module_id)" updatecommand="UPDATE [test_case] SET [test_case_name] = @test_case_name, [display_order] = @display_order, [test_module_id] = @test_module_id WHERE [test_case_id] = @test_case_id">
    <updateparameters>
    <asp:parameter name="test_case_name" type="String" />
    <asp:parameter name="display_order" type="Int32" />
    <asp:parameter name="test_module_id" type="Int32" />
    <asp:parameter name="test_case_id" type="Int32" />
    </updateparameters>
    <insertparameters>
    <asp:parameter name="test_case_name" type="String" />
    <asp:parameter name="display_order" type="Int32" />
    <asp:controlparameter name="test_module_id" type="Int32" controlid="_TestModuleId" propertyname="value" />
    </insertparameters>
    <selectparameters>
    <asp:controlparameter name="test_module_id" type="Int32" controlid="_TestModuleId" propertyname="value" />
    </selectparameters>
    </asp:sqldatasource>

     

    I will be forever greatful to anyone who can help.

  • Re: ReorderList InsertItem not sending in value to sortorderfield

    05-01-2009, 11:30 PM
    • Member
      point Member
    • trentmas
    • Member since 04-30-2009, 7:15 PM
    • Posts 2

    I still don't know how it works or why it now works, but got it working. I was setting the Delete statement in the codebehind and after sticking in on the ASPX page with the rest of the statements it began working. Why the delete statement had any bearing is a mystery to me.

  • Re: ReorderList InsertItem not sending in value to sortorderfield

    05-06-2009, 11:34 PM
    Answer

    Hi trentmas,

    Please have a look at my reply and sample codes in these threads, I think it will helpful to understand the Drag and Drop function of the ReorderList:
    http://forums.asp.net/p/1392144/2986476.aspx#2986476
    http://forums.asp.net/p/1380407/2929312.aspx#2929312
    http://forums.asp.net/p/1370007/2865830.aspx#2865830


    Best regards,

    Zhi-Qiang Ni

    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
Page 1 of 1 (3 items)