I have a page with a repeater.. I have to make some fields of this one editable. I don't see how I can transform the repeater label into a textbox.. Can I use jquery to do that?
Have somebody make this kind of manipulation?
Thanks..
The Repeater control does not have an EditTemplate like many of the other data controls.
I would suggest having the edit fields either in a hidden Placeholder, then show this when clicking an edit button. This would involve the page posting back and then you having to show/hide the relevant parts in the ItemCommand handler.
Another way would be do add the edit fields/textboxs in a Panel control, then hide this through display: none;. Then you can change this to display: block; with some javascript. This will avoid the page PostBack.
This can be done in a Repeater, but a DataList control is more straightforward and is just as easy to use. There's an MSDN article on doing it in a Datalist control with full source code here: http://msdn.microsoft.com/en-us/library/bf5211wb(v=vs.71).aspx
Converting a repeater to a DataList is a much easier approach than having editable items in a Repeater.
HOWEVER
to answer your question directly, there IS a Codeproject sample here: http://www.codeproject.com/KB/aspnet/EditableRepeater.aspx
that shows how to use a Repeater with full edit functionality (including adding and deleting items).
To see the relevant code in the CodePlex article, search for the text "EditIndex". The relevant code-behind is always a few lines above and/or below this keyword.
It depends on how you want to do this:
using standart control probably you need GridView.
You can define the template for repeater and put TextBox there, then
on postback you will need to find dynamically created controls and
also you will need to take care to keep ID's of these controls the
same on postbacks.
And the other thing - you can replace label with the textBox using
jQuery and then update value via Ajax reques.
You decide what you need :) Anyway it's a lot of samples in the internet.
Related
I'm completely newbie on ASP.net i just want to ask if what does it mean we they say Repeater is Editable? does it mean you can edit it while running on a browser?
The Repeater doesn't have EditTemplate .
I suggest you to make edit fields in a hidden Placeholder, show this when clicking an edit button.
Here is In-place Editing with ASP.NET Repeater example on CodeProject .
You can Edit and save the content using editable repeater.
Good documentation available in code project
Which source says a "repeater is editable"? The Repeater documentation suggests otherwise:
The Repeater control has no built-in selection capabilities or editing support.
By itself a Repeater doesn't allow much of anything except data-binding controls from a collection. Now, one could use two-way databinding to create "editable content", sure .. but that doesn't imply a "repeater is editable".
I have read many articles regarding difference between gridview and repeater. I come to know that gridview pattern is fixed in and , where as repeater can provide customized HTML mark up. If I am not wrong, we can also customize HTML mark up by adding template field and placing table with customized design. In that tables we can place labels and other .net control and can get whatever we want. Then why to use repeater control.
I am confused in which scenario it can be preferred over gridview.
In simple words we can say performance of repeater is far better than gridview. If you need basic rendering for read only items then its better to use repeater and if you need events , pagination and editable controls then you should go for gridview. Simpler controls with less in built functionality are speedy. you can do implement all functionalities of grid view to repeater but you have to do it manually.
So it depends upon you requirements either you need repeater or gridview
This discussion will be helpfull for you
http://forums.asp.net/t/1072020.aspx
I am using DevExpress's GridView. I have edit button working fine. I need to add a new custom linkbutton, which when clicked should show DevExpress's modal popupwindow to gather few input values and execute a method in codebehind. Please let me know how to do it. Not sure why it is so hard to achieve such a simple requirement.I couldn't find any sample code even for adding a custom link button!
I suggest that you get started with the E1120 example.
Your question is a little confusing as you mention GridView which is a Winforms grid but also mention CodeBehind which suggests Asp.Net
To Add repository items to the Winforms grid
If you are referring to the AspxGridView then you can use the standard Asp.Net Templating feature and add any control to a column.
I intend to use Javascript to dynamically create a group of html elements (input boxes, select list, radio button, etc.) each time the user clicks "Add More" button.
I have found the Javascript that does that here:
http://viralpatel.net/blogs/2009/01/dynamic-add-textbox-input-button-radio-element-html-javascript.html
http://forums.asp.net/p/1611284/4118564.aspx
So how do I get the values of these dynamically created HTML elements from code-behind? Is there a JQuery way which is better?
Thank you.
I think you'd may be able to do it with a callback/async postback to your ASP.NET page to update the control tree as you update. Not sure how the ViewState is updated/affected by this.
Otherwise, because your messing with the ViewState, so you'll need to revert to accessing them by the Request.Form object.
I have an "action" column in my repeater which shows actions a user can select for an item. The column contains ASP.NET HyperLink or LinkButton controls. Some actions are based on whether a user is in a role, which I determine programatically. I'm struggling with the best way to dynamically generate this column when I populate the repeater. Now I am assigning in-line code to the Visible property of each control, but I feel that is sloppy and not very straight forward. Would I be better served using a PlaceHolder control and populating that at runtime? What kind of methods do other people use for situations such as this?
The "normal" way to apply any sort of dynamic rendering to a Template based control such as the Repeater is to handle the ItemCreated or ItemDataBound events.
In your particular case, you could check appropriate conditions within that event handler and toggle the visibility of the relevant "Action" column.
Also, see this question where Ian Quigley posted a code snippet that should serve as a good example for you. It may also help to read my own answer which shows how to use visibility toggling in inline code.