Reorder List - Without ObjectDataSource

Last post 10-11-2007 4:33 PM by pmarkland. 38 replies.

Sort Posts:

  • Reorder List - Without ObjectDataSource

    04-23-2006, 7:42 PM
    • Contributor
      4,732 point Contributor
    • RTernier
    • Member since 06-05-2003, 1:40 AM
    • British Columbia, Canada
    • Posts 1,106

    I'm trying to play with the ReorderList control, but I'm not having any luck. We don't use front end ObjectDataSource controls.

    Here's my code:

    <atlas:UpdatePanel ID="aupReorderList" runat="server">

                    <ContentTemplate>

                        <div class="reorderListDemo">

                            <atlasToolkit:ReorderList ID="rlTasks" runat="server" OnItemDataBound="rlTasks_ItemDataBound">

                                <ItemTemplate>

                                    <div>

                                        <asp:Label ID="lblTaskName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>

                                    </div>

                                </ItemTemplate>

                                <ReorderTemplate>

                                    <asp:Panel ID="Panel2" runat="server" CssClass="reorderCue">

                                    </asp:Panel>

                                </ReorderTemplate>

                                <DragHandleTemplate>

                                    <div class="dragHandle">

                                    </div>

                                </DragHandleTemplate>

                                <InsertItemTemplate>

                                    <div style="padding-left: 25px">

                                        <asp:TextBox ID="txtInsertTask" runat="server" Text=""></asp:TextBox>

                                        <asp:LinkButton ID="lnkInsertTask" runat="server" OnClick="lnkAdd_InsertTask">Add</asp:LinkButton>

                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter some text" ControlToValidate="txtInsertTask"></asp:RequiredFieldValidator>

                                    </div>

                                </InsertItemTemplate>

                            </atlasToolkit:ReorderList>

                        </div>                   

                    </ContentTemplate>

                </atlas:UpdatePanel>

     

    And here's my Code Behind:

     

        private void BindList()

        {

            SqlConnection conTasks;

            SqlCommand cmdTasks;

            SqlDataAdapter dadTasks;

            DataTable tblTasks = new DataTable();

            conTasks = new SqlConnection("Server=ASIA-NEW\\SQL2005;Database=Tasks;User ID=rternier;Password=******");

            cmdTasks = new SqlCommand("EXEC TaskList", conTasks);

            cmdTasks.Connection.Open();

            dadTasks = new SqlDataAdapter(cmdTasks);       

            dadTasks.Fill(tblTasks);

            cmdTasks.Connection.Close();

            rlTasks.DataSource = tblTasks;

            rlTasks.DataBind();

        }

     

    When it renders, it renders the right amount of items, but doesn't put the text in. I've even used the ItemDataBound event and loaded the "name" field into the Label, and the name does go in there properly, but when rendered, it's empty.

     

    I took off all CSS to it would display as text.

     

    Any advice? 

    The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

    My Site | My Examples | My Blog


  • Re: Reorder List - Without ObjectDataSource

    04-24-2006, 3:18 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam

    You don't need to use the ObjectDataSource but you do need to use an object that derives from DataSource - just use SqlDataSource.  It's on the toolbox next to the ObjectDataSource, etc.  It'll be something like:

     

    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="Server=ASIA-NEW\\SQL2005;Database=Tasks;User ID=rternier;Password=******")" runat="server" SelectCommand="EXEC TaskList">      
           
            </asp:SqlDataSource>
           

    Note you'll need to specify a query for the update command and a field that is an integer column that hte ReorderList can modify for sorting (see the SortFieldID property).

    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Reorder List - Without ObjectDataSource

    04-24-2006, 5:56 PM
    • Contributor
      4,732 point Contributor
    • RTernier
    • Member since 06-05-2003, 1:40 AM
    • British Columbia, Canada
    • Posts 1,106

    Thank's sburke_msft. That should be good enough to show the powers that be.

    On another note, when they're fully released will we be able to bind say a DataTable or a List<T> to them?

    Our DB Consists of over 150 tables and 400 stored procedures. There is a huge array of security that goes on these SP's that is managed in our Data Tier and Data Logic sections so using the SqlDataSource, though effective for an example, doesn't help us in the full scheme of things.

    The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

    My Site | My Examples | My Blog


  • Re: Reorder List - Without ObjectDataSource

    04-26-2006, 4:19 AM
    • Member
      5 point Member
    • laurenznitert
    • Member since 04-12-2006, 9:45 AM
    • Posts 1

    What would this update command look like?

    I've got this:

    UpdateCommand="UPDATE [Messages] SET [ShowOrder] = @ShowOrder WHERE [MessageID] = @Original_ItemID">

    <UpdateParameters>

       <asp:Parameter Name="ShowOrder" type=Int32 />

       <asp:Parameter Name="MessageID" Type=Int32 />

       <asp:Parameter Name="Original_ItemID" Type=Int32 />

    </UpdateParameters>

    But is doesn't work

    Please advise.

    Regards,

    Laurenz Nitert

  • Re: Reorder List - Without ObjectDataSource

    04-26-2006, 2:16 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam

    You can bind to a datatable or a list but you'll need to do the reorder operation yourself.  There's an OnReorder event that allows you to do this. 

    For the UPDATE command, that should be fine, but there isn't enough information there for me to see what's wrong.  Make sure you've set the SortFieldID property of the ReorderList.

    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Reorder List - Without ObjectDataSource

    05-08-2006, 7:07 PM
    • Contributor
      4,732 point Contributor
    • RTernier
    • Member since 06-05-2003, 1:40 AM
    • British Columbia, Canada
    • Posts 1,106

    After trying to bind to a DataTable for awhile I still cannot do it.

    It's displaying the correct number of items in the List, however I can never get any text from the DataTable to be displayed in the Reorder list.

        private void LoadList()

        {       

            SqlConnection connList = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"].ToString());

            SqlCommand comList = new SqlCommand("EXEC sp_EAMeetingList 0", connList);

            SqlDataAdapter dadList = new SqlDataAdapter(comList);

            DataTable tblList = new DataTable();

            dadList.Fill(tblList);

            rlDemo.DataSource = tblList;

            rlDemo.DataBind();

        }

     

    ----

     

        <atlasToolkit:ReorderList ID="rlDemo" runat="server" DragHandleAlignment="Left"  ItemInsertLocation="Beginning" DataKeyField="MeetingTypeID" SortOrderField="MeetingOrder">

            <ItemTemplate>

                <asp:Label ID="Label1" runat="server" Text="This Displays Fine" />

                <asp:Label ID="Label2" runat="server" Text='<%# Eval("Type") %>' />

                </div>

            </ItemTemplate>

            <ReorderTemplate>

                <asp:Panel ID="Panel2" runat="server" CssClass="reorderCue">

                </asp:Panel>

            </ReorderTemplate>

            <DragHandleTemplate>

                <div class="dragHandle"></div>

            </DragHandleTemplate>      

        </atlasToolkit:ReorderList>

    ---

     

    "This Displays fine" is displayed, but the next label is never displayed even though when I break through it "type" is always something (not "")

     

    Any suggestions?

    The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

    My Site | My Examples | My Blog


  • Re: Reorder List - Without ObjectDataSource

    05-08-2006, 7:11 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam
    Hmmm - I notice a lonely orphaned "</div>" at the end of the ItemTemplate.  Could that be it?
    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Reorder List - Without ObjectDataSource

    05-09-2006, 1:04 PM
    • Contributor
      4,732 point Contributor
    • RTernier
    • Member since 06-05-2003, 1:40 AM
    • British Columbia, Canada
    • Posts 1,106

    Thanks for pointing that out. That wasn't hte issue however :( Even after removing it, the data that is supposed to be bound from the DataTable/DataBase is still not binding.

    The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

    My Site | My Examples | My Blog


  • Re: Reorder List - Without ObjectDataSource

    05-09-2006, 7:23 PM
    • Contributor
      4,732 point Contributor
    • RTernier
    • Member since 06-05-2003, 1:40 AM
    • British Columbia, Canada
    • Posts 1,106

    OK, I got it working on my local box using SQLDataSource. However, I'm having an issue with it.

    You can see the complete example here:

    http://projects.bicnet.org/Atlas/Toolkit/Reorderlist/ReorderListExample.aspx

    First thing you'll notice is that my LI's are visible, I'll fix that on my next update, however it's not allowing me to reorder or do anything like that. Could this be because my web host is blocking the Atlas scripts (Doubt it) or could it be because of the masterpage I put my code in?

    The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

    My Site | My Examples | My Blog


  • Re: Reorder List - Without ObjectDataSource

    05-10-2006, 11:53 AM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam

    Yes SqlDataSource will work just fine - if you can do it that way, just stick with that.  I'll need to sit down and see why a normal data source or list didn't work.

    I assume you know, but all it takes to get rid of the bullets is set style="list-style:none".

    In any case, I do get the reorder behavior when I hit that page so it's basically working.  When I drop an item I get a server-side error about the ConnectionString not being initialized (I think you need to drop the "!IsPostBack" from your Page_Load).

    So basically I don't know why you're not getting reorder behavior.  Let me know what you find out.

    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Reorder List - Without ObjectDataSource

    05-10-2006, 12:16 PM
    • Contributor
      4,732 point Contributor
    • RTernier
    • Member since 06-05-2003, 1:40 AM
    • British Columbia, Canada
    • Posts 1,106

    What do you use to tell you that you're getting the reorder behavior? I can't tell at all that anything is processing.  I'll do some more testing.

    Thanks for the help so far.

    --Edit:
    It works fine with Mozilla / FireFox. It doesn't work with IE 7 B2 on my live site... but it does work with IE7 B2 on my local testing box...

    The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

    My Site | My Examples | My Blog


  • Re: Reorder List - Without ObjectDataSource

    05-10-2006, 1:50 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam
    Maybe I misunderstood - I can drag the things around just fine, and I get hte post back (and the error) when I drop them.  I thought you weren't even seeing that?
    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Reorder List - Without ObjectDataSource

    05-10-2006, 1:54 PM
    • Contributor
      4,732 point Contributor
    • RTernier
    • Member since 06-05-2003, 1:40 AM
    • British Columbia, Canada
    • Posts 1,106

    I was testing in IE7. I couldn't drag, so I couldn't see that error. When you said you could, I tried Firefox, which showed me what you were seeing.

    I've resolved that and it works fine now. I moved my connection string to the front end, binding it using:

    ConnectionString='<%$ ConnectionStrings:bnDefaultCS %>'

    It works fine... except it doesn't work in IE7 beta 2 (7.0.5346.5)

    The Killer Ninja Coding Monkeys thank those that mark helpful posts as answers.

    My Site | My Examples | My Blog


  • Re: Reorder List - Without ObjectDataSource

    05-10-2006, 1:56 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam
    Hmmm, you're on a newer IE build than I am.  I'm on IE7 as well and it is working for me.  Uh oh, I'll look into that....
    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Reorder List - Without ObjectDataSource

    05-11-2006, 12:53 PM
    • Contributor
      4,346 point Contributor
    • sburke_msft
    • Member since 04-04-2006, 7:28 PM
    • Redmond, WA
    • Posts 770
    • AspNetTeam

    I'm trying your example at

    http://projects.bicnet.org/Atlas/Toolkit/Reorderlist/ReorderListExample.aspx

    With the released B2 IE7 build and it's working fine.  Does that not show the problem?

    Don't forget, this posting is provided "AS IS" with no warranties, and confers no rights.
Page 1 of 3 (39 items) 1 2 3 Next >