C# - Reorder Items In DataView Object?
Jan 24, 2010
I have a DataView object with productID and productName,i get all items from Products Table and store them in Cache.I want to get items that user bought in order he bought them without using another query or joining tables. ie.
Products DataView
1. Foo
2. Foo2
3. Foo3
Filtering to ProductsBoughtByUser using RowFilter (productID in (1,3))
UserProducts DataView
1.Foo
3.Foo3
Now user first bought Foo3, how do i reorder items based on correct ( chronological ) Array. ie 3 1
View 1 Replies
Similar Messages:
Jul 6, 2010
I have tried several examples of reorder list with several types of data sources and can't get the list to reorder. I have copied Joe Stagner's code from his Video on Reorder Control with the same result. Here is the Video
http://www.asp.net/ajax/videos/how-do-i-the-ajax-toolkit-reorder-control. Page loads, but I can't drag items to reorder. I have tried this with explorer 8 and firefox 3.6, with and without security. Here is the markup, no code behind.
[Code]....
Some of the events don't seem to fire. DataBinding, DataBound, Load, and InsertCommand work ItemReorder does not, (not good for a reorder control). This control should work, but doesn't. I am able to insert data so it seems that the reorder or dragItem templates maybe causing problems. I have commented out but that doesn't help. Here is my only clue, I had to use the script manager from the .net4 Ajax Control Kit for my events to not complain about definitions. I was only using these events with debugger just to see if they are being called, no code in methods. But I am using the toolkit.dll that came with Joe's example. I tried it with .net4 only first, but that didn't work either that's when I installed the dll from Joe's example.
View 1 Replies
Jul 7, 2011
Is there a way to drag and drop the item in a listbox to reorder the sequence?
View 8 Replies
Jan 13, 2010
I am trying to use
[Code]....
with values I get from a database but I am getting Object reference not set to an instance of an object.
View 11 Replies
Jul 11, 2010
I'm using DropDownList within my WebApplication. I need to keep additional piece of information with each Item on list. How can I achieve this?
View 3 Replies
Feb 1, 2011
When and how do I use the Httpcontext.items dictionary object?
View 2 Replies
Sep 13, 2010
For my site, I have a list of users and a list of events. I will be assigning users to each event. I have a table named EventUsers to hold this data:
EventUsers
EventID | UserID
1 | 123
1 | 456
2 | 789
On my page, I want to be able to add and remove users for a certain event. I could have a dropdown populated with users and an "Add" button next to it, then when I want to add a user, I pick one and click "Add". There would be a grid below it displaying all the users for the event, with "Delete" buttons for each one. The downside to this is that a database call is made for every Add and Delete.
Another option is to have two listboxes on the page - one on the left containing all users in the database, and another on the right which will contain users for the given event, and I can just add or remove from the list on the right. Then when I'm done, I click save, and it makes one database call. The only issue is that if I'm removing and adding, I'll have to delete every record in my EventUsers table for that event, and then add the changes. I've run into this before, and I've always gone with the dropdown method. What's the preferred method here?
View 3 Replies
Mar 6, 2011
1: I have a .html file that has some markup with some placeholder tags.
[code]...
4: PersonInfo.aspx is literally empty since I am injecting html from code-behind.
When the PersonInfo.aspx is called the html-template markup with appropriate values in the placeholder will be displayed. Also there are chances I would like to send the final markup in an html email (though that is not part of the question as I know how to email).
Is this the best way to fill values in my html-template or is the any other better alternative?
Note: This is a very simple sample example. My class is very complex involving objects as properties and also my html template have 40-50 placeholders.
So code in my step 3 will need 40-50 Replace statements.
View 3 Replies
Jun 23, 2010
I have a multiview inside an updatepanel. in one of the views, I save a value in a session object like this:
Session["xyz"] = "some string value";
Then I switch to another view and try to pick it up the value in a button's OnClick event:
string x = Session["xyz"].ToString();
But I get a null reference error. Debugging it shows that Session["xyz"] is indeed null, yet other Session variables are still there. Is there something special about Session and AJAX?
View 5 Replies
Feb 1, 2010
There are a few posts on the site about how to order by using lambda expressions however I cannot seem to get mine to work. I am trying to reorder a list that is already populated. Am i wrong in thinking that i can rearrange the order of this list using lambada expressions?
QuarterMileTimes.OrderByDescending(c => c.PquartermileTime);
I was wondering if it's down to PquartermileTime being a string? I also tried this expression on a date
QuarterMileTimes.orderBy(c => c.RaceDay);
View 5 Replies
Dec 30, 2010
I'm attempting to use the List Reorder from here: [URL] I've got all the scripts in place, and my events are firing properly on dragging/dropping, but I'm unable to see anything in my object. The goal is to reorder the list, and save the new order back to the DB. I am assuming something is wrong with my syntax in the lists.bind, as it shows the actual items in the list, but the values are empty.
$(document).ready(function () {
var options = {
itemHoverClass: 'itemHover',
dragTargetClass: 'dragTarget',
dropTargetClass: 'dropTarget',
useDefaultDragHandle: true
};
var lists = $('.lists').ListReorder(options);
var items = [];
lists.bind('listorderchanged', function (evt, jqList, listOrder) {
for (var i = 0; i < listOrder.length; i++) {
items[i] = $("ul li:eq(" + i + ")").attr('id');
}
});
$('#btnSave').click(function () {
if (items.length > 0) {
var jsonText = JSON.stringify({ items: items });
$.ajax({
type: "POST",
url: 'ManageSliders.aspx/SaveReOrder',
data: jsonText,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () { $("#result").html("New order saved successfully"); },
failure: function (msg) { alert(msg); }
});
}
else {
alert("You have made no changes");
}
});
});
I'm binding a listview using C# and that is showing up fine as well.
<ul class="lists">
<asp:ListView ID="lvSliders" runat="server">
<LayoutTemplate>
<asp:Panel ID="itemPlaceHolder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<li id='<%# DataBinder.Eval(Container.DataItem, "Id")%>'>
<%# DataBinder.Eval(Container.DataItem, "Title")%></li>
</ItemTemplate>
<ItemSeparatorTemplate>
</ItemSeparatorTemplate>
</asp:ListView>
</ul>
I ran it through Fiddler, and it is throwing me this error:
{"Message":"Cannot convert object of type u0027System.Stringu0027 to type u0027System.Collections.Generic.List1[System.String]u0027","StackTrace":" at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary2 rawParams)
at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary2 parameters)
at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary2 rawParams)
at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}
View 3 Replies
Jul 5, 2010
I have an object on the webpage that I normally will attach a source to. When doing that as in the code below it works fine.But if I have a empty string for setSrc1, then the webpage shows a message in the left down corner that:
"1 items remaining" Waiting for...
How would it be possible to not have this message if no src is set to the Object1 ?
[Code]....
View 3 Replies
Sep 30, 2010
I have the same problem as Simon in this post. He found out some sort of a solution, but it does not work for me. Please, could someone explain me what is going on in this answer or advice me something else. PS: there is an example on the asp.net site which doesn't work exactly the same way as my reorder list... (click view a demo) The solution that is suggested here adds these few lines to web.config:
[Code]....
Perhaps I just need to change something to make it work... but I don't know what. For example I have no idea what the ScriptResource.axd is supposed to be. My code: .aspx file
[Code]....
and the code behind
[Code]....
I load the data to the List collection from the page_load event but that works fine. The data binding works as well. The problem is in that the items cannot be reordered -- during the reordering, the sort value doesn't change and the list doesn't update.
View 2 Replies
Sep 29, 2010
I have the same problem as Simon in this post. He found out some sort of a solution, but it does not work for me. Please, could someone explain me what is going on in this answer or advice me something else. PS: there is an example on the asp.net site whh doesn't work exactly the same way as my reorder list... (click view a demo) The solution that is suggested here adds these few lines to web.config:
<httpHandlers>
<add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
Perhaps I just need to change something to make it work... but I don't know what. For example I have no idea what the ScriptResource.axd is supposed to be. My code: .aspx file
<%@ Page Title="" Language="C#" MasterPageFile="~/editor/editor_template.Master" AutoEventWireup="true" CodeBehind="menuEditor.aspx.cs" Inherits="WebPageEditor.editor.menuEditor" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="DeleteMenu" InsertMethod="InsertMenu" SelectMethod="SelectMenu"
TypeName="WebPageEditor.editor.MenuSourceManager" UpdateMethod="UpdateMenu"
>
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="url" Type="String" />
<asp:Parameter Name="order" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="url" Type="String" />
<asp:Parameter Name="order" Type="Int32" />
</UpdateParameters>
</asp:ObjectDataSource>
<asp:ReorderList ID="ReorderList1" runat="server" AllowReorder="True"
DataSourceID="ObjectDataSource1" PostBackOnReorder="False"
ShowInsertItem="True" SortOrderField="order" DataKeyField="ID"
ItemInsertLocation="Beginning">
<ItemTemplate>
<div class="menuEditor">
» <%# Eval("name") %>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit">LinkButton</asp:LinkButton>
</div>
</ItemTemplate>
<DragHandleTemplate>
<img src="ico/moveHandle_ico.gif"
alt='<asp:Literal ID="Literal1" runat="server" Text="<%$ Resources: editorLocalization, ME_moveHandleTT %>" />'
style="cursor:move; width:35px;" />
</DragHandleTemplate>
<ReorderTemplate>
<asp:Panel runat="server" />
</ReorderTemplate>
<InsertItemTemplate>
<asp:Panel ID="panel1" runat="server" DefaultButton="Button1">
<asp:TextBox ID="TextBox1" runat="server" Text=' <%# Bind("name") %>' ValidationGroup="add" />
<asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Add" ValidationGroup="add" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ValidationGroup="add"
ErrorMessage="Please enter some text" ControlToValidate="TextBox1" />
</asp:Panel>
</InsertItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("name") %>' ValidationGroup="edit" />
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("url") %>' ValidationGroup="edit" />
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("order") %>' ValidationGroup="edit" />
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update">LinkButton</asp:LinkButton>
</EditItemTemplate>
</asp:ReorderList>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
and the code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace WebPageEditor.editor
{
public class MenuSourceManager
{
public static List<MenuItem> menuItems;
#region DataBindMethods
//[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select)]
public List<MenuItem> SelectMenu()
{
return menuItems;
}
public void UpdateMenu(int ID, string name, string url, int order)
{
menuItems[ID].Name = name;
menuItems[ID].Url = url;
menuItems[ID].Order = order;
}
public void InsertMenu(string name, string url, int order)
{
menuItems.Add(new MenuItem(name, url, order, menuItems.Count));
}
public void DeleteMenu(int ID)
{
menuItems.RemoveAt(ID);
}
#endregion
}
public class MenuItem
{
public MenuItem(string name, string url, int order, int ID)
{
Name = name; Url = url; Order = order; this.ID = ID;
}
public string Name { get; set; }
public string Url { get; set; }
public int Order { get; set; }
public int ID { get; set; }
}
}
I load the data to the List collection from the page_load event but that works fine. The data binding works as well. The problem is in that the items cannot be reordered -- during the reordering, the sort value doesn't change and the list doesn't update.
View 2 Replies
Jul 27, 2010
I am using autogeneratecolumns ="false" and using some template fields.
It works when I use:
tempColumnNew = Me.DataGrid.Columns(oldColIndex)
tempColumnOld = Me.DataGrid.Columns(newColIndex)
Me.DataGrid.Columns.RemoveAt(oldColIndex)
Me.DataGrid.Columns.RemoveAt(newColIndex)
Me.DataGrid.Columns.AddAt(oldColIndex, tempColumnOld)
Me.DataGrid.Columns.AddAt(newColIndex, tempColumnNew)
But it doesnt remember the added columns on postback, so I have to add them for every postback.
Is there a better way to implement it?
View 2 Replies
Dec 9, 2010
I am using asp.net ajax reorder list for one single page. It works fine for other computers on our network, except one computer. Regardless what browser she's using, it doesn't work. Is there a setting on the workstation's browser to allow asp.net ajax or something?
View 1 Replies
Sep 20, 2010
is it possible to have a drag and drop reorder on a gridview? The purpose is to reorder the items.
View 3 Replies
Aug 31, 2010
Reorder list to do control placement
[Code]....
View 4 Replies
Aug 4, 2010
I' m using Reorder list sample for the first time. When it is bound with datasource, and reordered it is working fine. but unfortunately on postback to the server, i',m not getting the reordered items.
View 5 Replies
Jan 12, 2011
i am fighting alot with reorderlist today. So far, i seem to be loosing. I can't seem to get it to work, when i bind directly to my sqldatasource. Instead, i have tried to feed it a datatable, and bind on pageload. BUT, when i do a reorder, that affects the 1st entry in the list, it tells me the index was outside the bounds of the array.
View 2 Replies
Sep 2, 2010
Im using a toolkit reorder list control. Im using LINQ2SQL. I have troubles making the order changes in the list to be updated to the database. This is my aspx code:
[Code]....
The drag and drop reordering works fine. In my
[Code]....
But no changes to the order are visible. What is missing?
[Code...]
View 2 Replies
Jul 13, 2010
Reorder list control cannot be set to not postback? My hope for this control was that I could tie it to a list of data (either a datasource or even a manually created list) and then allow the user to move the items in the list up and down until they liked the new order of all of the elements. They then would click a button to save the updates to the database. Is this possible? It seems that after every reorder there is a postback requried to the datasource to perform an UPDATE, even if the PostBackOnReorder
="false"
value is set.
So if my list is
1 Atlanta
2 Boston
3 Chicago
4 Denver
5 Edmonton
and they want to switch Denver with Boston and then hit the Update List button I could cycle through the list an only update two entries rather than all 5 entries twice (for each Postabk on reorder)
View 1 Replies
Jan 6, 2010
I have an issue with the appearance of my reorder list. The draghandle div is outside of the item template div. I have used the reorder list in the past and the draghandle was always inside of the item template. I can't seem to find any mistakes so is this a bug or do I have a mistake somewhere. All other functionality works great. Here is the code.
[Code]....
View 1 Replies
Jun 20, 2010
I did the tutorial for the ReorderList on the asp.net site: http://www.asp.net/ajax/tutorials/drag-and-drop-via-reorderlist-cs and everything works perfectly. But for some reason when I switch out the references and use the same code for my db table the changes aren't saving. In other words when I use the db table called 'AJAX' that I created based on the tutorial everything works perfectly, but when I use it on my table ('projects') the changes don't save to the db. I can't think of anything in the db that would be causing this to happen.
Here's my code:
//This works
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="asm" runat="server" />
<div>
<asp:ReorderList ID="rl1" runat="server"
SortOrderField="position"
[Code]....
View 5 Replies
Feb 20, 2011
I have an AJAX Reorder List control, which is working fine. I want to add an "Edit" hyperlink to the ItemTemplate (which I have done) that opens an AJAX Modal Window when it's clicked. I need to add an OnClick attribute to call a javascript function and pass the value for the ID of the object bound to the list. I have done this before with a gridview with no problem - I just need to add code like this to RowDataBound event:
If e.Row.RowType = DataControlRowType.DataRow Then
Dim HyperLink1 As HyperLink = e.Row.FindControl("HyperLink1")
HyperLink1.Attributes.Add("onclick", "ShowPopup('" & myGridControl.DataKeys(e.Row.RowIndex).Value & "')")
View 1 Replies