I would like to change the listview template on a button click event. for example if your in edittemplate i would like to switch to ItemTemplate.
i am trying to do this because im writing my own custom update function for the list view. so after i successfully update the row, it doesn't switch back to the default view.
Rgds
Adrian
Adrian,
As you have tagged this as an asp.net question I would direct your attention to jquery (jquery.com). If you use a vanilla template (wrapping your elements in simple "div" tags) and use the jquery tools to do addClass/removeClass and toggleClass and apply various css styles to achieve the visual effect you desire you should be able to land just were you wish.
Using page methods you can leverage your custom update on a partial postback from jquery and reduce the server impact.
If you would rather do this server side you are probable looking to leverage the item databound event to set your template.
A more complete answer would require more information about what you are trying to accomplish.
Cheers,
CEC
Related
i need a solution like this:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/checkboxes/defaultcs.aspx
however, i need the user to be able to add entries in here.
does such a control already exist?
it can be either jquery or asp.net
it also does not have to be a combobox, it can be a listbox. i need to have every item have a checkbox next to it and be able to add a comment for each entry.
Take a look at the ASPxGridLookup control from the DevExpress component vendor.
The ASPxGridLookup component allows the implementation of the multi-select DropDown functionality:
http://demos.devexpress.com/ASPxGridViewDemos/ASPxGridLookup/MultiSelect.aspx
http://www.devexpress.com/example=E3467
http://codecentral.devexpress.com/E3467/
with editing capabilities via the embedded ASPxGridView object:
http://demos.devexpress.com/ASPxGridViewDemos/GridEditing/EditModes.aspx
Ref : DropdownList with Multi select option?
Multiple dropdownlist with checkbox....checkout below link...
checkout demo page here...
http://download.ysatech.com/ASP-NET-Multiple-Selection-DropDownList/ASP-NET-Multiple-Selection-DropDownList.aspx
Blog page here....
http://blog.ysatech.com/post/2009/09/09/ASP-NET-Multiple-Selection-DropDownList-with-AJAX-HoverMenuExtender.aspx
http://www.codeproject.com/KB/user-controls/MultiSelectDropdownList.aspx
To me it sounds like it might be better for you to run with a ListBox. Telerik offers the RadListBox, which allows you to have checkboxes as seen here.
Additionally, you could allow for edits upon, for example, double-click as is displayed in the source code attached to this forum post.
Finally, if you want to also display the comments then you could use an ItemTemplate to define a custom layout for each RadListBoxItem and allow the user to edit both the main and comment fields.
That should cover everything that you need.
How can I create a dynamic drop down list without using AutoPostBack. I ask because I just want to change the value of what the second drop down list displays and then the user clicks a button and it submits. But If I use AutoPostBack then it postbacks to page and runs code that shouldn't be run until that final box has been selected. (I use Postback in the other part of my program so using !IsPostBack isnt a option.) I looked at Javascript but ASP generates all of its controls names at runtime. What can I do? I have looked at the Ajax CascadingDropDown control but my problem with that is it contained in a XML file or a Database, I need this to be contained inside my Page. Any Ideas?
You can use the CascadingDropDown control from the AJAX Control Toolkit
Maybe this example will help? It's part of the ASP.NET AJAX Control Toolkit available here.
You can use AJAX to get the values for the second drop down list, based on the selected value of the first. Add a onchange event handler on the client-side to the first drop down list that makes the AJAX call and fills the second on success.
My web page will get a set of results from the database and display it to the user. However I am not sure about "number" of results.
Each result will have a panel which contains several controls in itself, an image, several labels, etc.
What is the best way to do this dynamically, eg. create these controls dynamically?
Is it better to use an AJAX control? Should I use Gridview?
Thanks for the help,
Behrouz
You need to give us more details about how each result will look like.
I would being by looking at a repeater control. You don't need to know the number of results that get passed to it. You'll be able to specify a template for how each result will look like and the repeater control will take care of rendering one for each result.
A repeater is probably the better option for that scenario.
Add all the controls you're likely to need and switch them on and off as needed via the item databound event.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.itemdatabound.aspx
If the template for each item is the same, use a Repeater. Bind via AJAX if you'd rather bind via web services and save on server-side performance. Then you have to manage everything on the client, which can be tedious, but very performant. Use JQuery to make it easier.
Server-side adding of controls can be a pain, but doable.
HTH.
I am trying to generate a gridview dynamically through codebehind. So I am making all the columns through code using BoundField and other controls.
Now I am trying to to put a edit button in the gridview sand program that(I made a RowEditing handler). Right now all my code is in the page_load but when I hit the edit button in the gridview I get 2 gridviews back on post back.
So I tried to put a isPostback if statement to stop this but then I just get a error back saying it can't find the handler.
So I am not sure what to do.
Thanks
Depends how you created the control, what version of Visual Studio, and how nested it is.
For example I currently just went backwards a bit in technology.
I'm using 17 gridviews on a page that are all sql server 2000 driven from code behind and i have a dropdown in the grid for even row as well.
vs 2005 2.0 is what i am using.
I'm using a Master Page (which typically will not be a problem from gridviews, but will need ResolveUrl for jquery references)
Getting to your question, I seem to have that problem with .net asking for a handler when i would tend to copy and paste from .aspx html source. I have MultiView/View/FormView etc... so I tried CTYPE etc..., but upon re-doing the edit with being on the aspx page design view, then use properties and the events. Or if it is a link or button on the page then click on it in design view and it should take you there and NOT have a problem with the Handles.
Some of my code for Edit Button
etc.....
THEN in your properties -> Events, look for "RowEditing" and write in a name then put breakpoints in where it is called and you are there really for edit mode...
I only use 2 other events "RowCancelingEdit" and then "RowUpdating"
Thus I click Edit (which everything is readonly), and a postback occurs (eventually i was to be doing grids again with ajax and not have postbacks) then my fields are in edit mode and dropdown shows list from database as well .... I can update or cancel.... either way it ends in back to readonly state with Edit button visible.
Please post some code if you are still having issues with it.
I would like to move items from one list to another on a page, and I'm pretty flexible about what type of a list it is. What's the best way to do that? ASP.NET Ajax? jQuery? Anything else?
There's a nice tutorial on CodeProject that covers dragging with ASP.NET and jQuery:
http://www.codeproject.com/KB/webforms/JQueryPersistantDragDrop.aspx
if you want to do this and PostBack instead of using AJAX to update your data based on from fields you'll need to get creative about what types of controls you use. Page validation will complain about ASP controls like dropdownlists, listboxes, etc. if they contain selected items that weren't in the list when it was rendered.
Better to use AJAX to send back your updates or use HTML controls like unordered lists or select added via javascript and stuff the selected data in another control that doesn't complain (hiddenfield) on PostBack. The alternative is turning off page validation and I don't think that's a good idea.
You can also might look at YUI Library, I'd say it implements Drag & Drop in a very simple and flexible way:
http://yuilibrary.com/yui/docs/dd/
There are a lot of examples etc...