Here is my page setup code:
Expand|Select|Wrap|Line Numbers
- <cc1:ReorderList ID = "reorderlst" runat="server" PostBackOnReorder="True" SortOrderField="ListOrder"
- DataKeyField="T_id" DataSourceID = "odslist" AllowReorder ="True" >
- <ItemTemplate>
- <div class ="itemArea">
- <table style="border-bottom: solid 1px #C0C0C0">
- <tr id ="rowReorderItem">
- <td>
- <asp:Label ID ="lblListorder" runat="server" Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("ListOrder"))) %>' />
- </td>
- <td>
- <asp:Label ID ="lbltitle" runat="server" Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Title"))) %>' />
- <asp:Label ID ="lblid" runat="server" Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("T_id"))) %>' />
- </td>
- </tr>
- </table>
- </div>
- </ItemTemplate>
- <EmptyListTemplate>
- <div>
- <strong> No task exists</strong>
- </div>
- </EmptyListTemplate>
- <ReorderTemplate>
- <asp:Panel ID="pnlReorder" runat="server" CssClass="reorderCue">
- </asp:Panel>
- </ReorderTemplate>
- <DragHandleTemplate>
- <asp:Image ID="imgReorder" runat="server" AlternateText ="move" ToolTip="Click and drag to reorder" ImageUrl="~/images/reorder.gif" />
- </DragHandleTemplate>
- </cc1:ReorderList>
- <asp:ObjectDataSource ID ="odslist" runat="server" SelectMethod="GetList" TypeName="fizmo.TodoList"
- UpdateMethod="ReorderTodoList" OnSelecting="odslist_Selecting" >
- <SelectParameters>
- <asp:Parameter Name="agentid" Type="Int32" />
- </SelectParameters>
- <UpdateParameters>
- <asp:Parameter Name ="listid" Type="Int32" />
- <asp:Parameter Name = "Title" Type="String" />
- <asp:Parameter Name="listorder" Type="Int32" />
- <asp:Parameter Name="agentid" Type="Int32" />
- </UpdateParameters>
- </asp:ObjectDataSource>
Here is by code behind
Expand|Select|Wrap|Line Numbers
- protected void odslist_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
- {
- Agent agt = new Agent(User.Identity.Name.ToString());
- e.InputParameters["agentid"] = agt.getagentid();
- }
Expand|Select|Wrap|Line Numbers
- namespace fizmo
- {
- public class TodoList
- {
- //data members
- private int _id;
- private string _title;
- private string _details;
- private DateTime _creationdate;
- private DateTime _expirationdate;
- private int _agentid;
- private ListPriority _priority;
- private int _ListOrder;
- //constructors
- public TodoList() { }
- public TodoList(string TodoTitle, string TodoDetails, DateTime Todocreationdate, DateTime Todoexpirationdate, int Todoagentid, ListPriority TodoPriority, int ListOrder)
- {
- this.Title = TodoTitle;
- this.Details = TodoDetails;
- this.CreationDate = Todocreationdate;
- this.ExpirationDate = Todoexpirationdate;
- this.AgentID = Todoagentid;
- this.Priority = TodoPriority;
- this.ListOrder = ListOrder;
- }
- public TodoList(string TodoTitle, string TodoDetails, DateTime Todocreationdate, DateTime Todoexpirationdate, int Todoagentid, ListPriority TodoPriority)
- {
- this.Title = TodoTitle;
- this.Details = TodoDetails;
- this.CreationDate = Todocreationdate;
- this.ExpirationDate = Todoexpirationdate;
- this.AgentID = Todoagentid;
- this.Priority = TodoPriority;
- }
- public TodoList(string TodoTitle,DateTime Todocreationdate, DateTime Todoexpirationdate, int Todoagentid, ListPriority TodoPriority)
- {
- this.Title = TodoTitle;
- this.CreationDate = Todocreationdate;
- this.ExpirationDate = Todoexpirationdate;
- this.AgentID = Todoagentid;
- this.Priority = TodoPriority;
- }
- public TodoList(int Todoid)
- {
- this.TodoID = Todoid;
- }
- //getter n setters
- public int ListOrder
- {
- get { return _ListOrder; }
- set { _ListOrder = value; }
- }
- public int TodoID
- {
- get { return _id; }
- set { _id = value; }
- }
- public string Title
- {
- get { return _title; }
- set { _title = value; }
- }
- public string Details
- {
- get { return _details; }
- set { _details = value; }
- }
- public DateTime CreationDate
- {
- get { return _creationdate; }
- set { _creationdate = value; }
- }
- public DateTime ExpirationDate
- {
- get { return _expirationdate; }
- set { _expirationdate = value; }
- }
- public int AgentID
- {
- get { return _agentid; }
- set { _agentid = value; }
- }
- public ListPriority Priority
- {
- get { return _priority; }
- set { _priority = value; }
- }
- public void ReorderTodoList(int listid, string Title, int listorder,int agentid)
- {
- string strsql = " Update Thingstodo set Listorder = @list where T_id = @listid";
- SqlConnection conn = new SqlConnection();
- String constr = ConfigurationManager.ConnectionStrings[("USBSRVR")].ConnectionString;
- conn = new SqlConnection(constr);
- SqlCommand cmd = new SqlCommand(strsql, conn);
- cmd.Parameters.Add("@list", SqlDbType.Int).Value = listorder;
- cmd.Parameters.Add("@listid", SqlDbType.Int).Value = listid;
- try
- {
- conn.Open();
- cmd.ExecuteNonQuery();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- conn.Close();
- }
- }
- public DataSet GetList(int agentid)
- {
- DataSet list = new DataSet();
- string strsql = " Select T_id, Title, Listorder from Thingstodo where Agentid= " + agentid + " and expirationdate >= " + DateTime.Now.ToShortDateString();
- SqlConnection conn = new SqlConnection();
- String constr = ConfigurationManager.ConnectionStrings[("USBSRVR")].ConnectionString;
- conn = new SqlConnection(constr);
- try
- {
- SqlCommand cmd = new SqlCommand(strsql, conn);
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- da.Fill(list);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- conn.Close();
- }
- return list;
- }
- }