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.