How to repeat textboxes and check box dynamically using repeaters - c#

I have requirement in my application where I am struck . These is my scenario:
Initially I need to show up two text boxes with a check box and a button. upon clicking the button we need to generate one more row. Like wise we need to create multiple rows dynamically.
Initially I tried with Table Control but after struggling a lot, I came to know that we can create only one row dynamically using Table Control. So now I am planning to do in repeater control.

In this kind of scenario, it would be better to use the GridView Control Instead, take a look here some working examples:
http://www.revenmerchantservices.com/page/gridview-add-new-row.aspx
http://amitpatriwala.wordpress.com/2008/04/18/inserting-new-row-in-gridview-in-aspnet-20/

Related

Add extra columns after initial load (Telerik MVC Grid)

I want to be able to add extra columns after the grid has been loaded. The user should be able to submit a form from the top of the page where the user may checks a checkbox, and then the page updates with the newly added column to the grid.
As an example, if I have two columns from the initial load and the user wants to add a third column. How can I achieve this technically? I saw an example of creating a new GridColumnSettings, though I don't think that's what I want.
The Telerik documentation about column settings is pretty good:
http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-columns.html#ColumnConfig
I feel like you have two options.
One is to use the Hidden method when generating the columns, and then use javascript to "un-hide" the extra columns when they click a button.
The other option is to selectively render the columns or not on the sever side. Take the value of the checkbox, and pass that to the Visible method of the column in your column definintion code.

Call code behind c# function from javascript

I know this has been asked, but none of the numerous answers fit with my situation. So I will humbly ask if someone can walk me through this again gently.
Environment: .Net 4 web app using c#, javascript, jquery, sql server, and entity framework.
Question: I need to be able to allow a user to "quick add" a value into a table that is bound to a drop down box without losing values a user has already entered onto current page. I don't care if I have to do a postback or use jquery or use ajax, etc. I need the functionality first - prettiness later ... the scenario is described below if you care to keep reading. With all that being said, I would love for this to be smooth and not "clunky" for the user.
Scenario:
I have a page where the user is able to enter many pieces of information into textboxes, static drop down boxes, and drop down boxes that are bound to other tables that will all get combined and inserted into one table. Well, it never fails, a user could be filling in the page and when they get to one of the table bound drop down boxes - a value is missing or they haven't added something item yet. I would like to add a button or link or something next to that drop down box that would allow the user to "quick add" an item to the table that fills that drop down box and then refresh the drop down box so they can choose that new value from the list ... all while not losing the other data on the screen they already entered.
What I've tried:
-Tried WebMethod option. Currently, this web page calls some custom "bind" methods in the code behind to fill drop down boxes so they are not filled directly from objects from entity framework. So that means using a static method will not work for a solution because part of the static function would need to call the bind method to refresh the drop down box with the newly inserted values.
-Tried PageMethod option. Some of the other samples used Page Method settings, but my site uses master and content pages and the posts seem to state that the page method route was not going to work.
Make sense?
Add an UpdatePanel to the page. The update panel should wrap the drop down to be added, as well as the textbox/button for adding a new entry to that drop down. You would want to have a different UpdatePanel for each dropdown/button pair, if applicable.
When they click the button inside of the update panel you can read the textbox, add an extra item to the drop down, and send an update to the database. (I'd manually add the new value to the drop down rather than updating the database and re-binding, if possible, but it may not be.)
The magic of UpdatePanels will make sure that this is all asynchronous and so doesn't disturb the user working on the page.

Web application Listview question

In a list view in C# how can I make all the fields in a column editable at once? Right now I have the standard edit button which allows me to update just one line at a time. I want the end user to be able to click a button and allow then to edit the column in its entirety.
Rebind the ListView with all TextBoxes when the user clicks edit.
You would have to manually track if you're in edit mode or not and on postback loop through all the rows retrieving the values from the textboxes and store them.
There is no built-in functionallity for what you're trying to do but it's possible.

Storing a collection into a list and session - Front End

I have this program in which I am trying to store a collection of values into a list and session
Example:
valueCollection = (List<Values>)Session["Value"];
I want to do the front end in a way which will show a table with each row showing a label and textbox. This would be too simple to do obviously but I want it to show 4 rows of the table by default and then the user can select "add another" this will then add another row onto the table with a label and textbox exactly similar to the 4 default. Everytime the user selects "add another" the table increments by 1.
How do you do something like that, or is there an easy way?
Here is a screenshot to explain it better:
http://img828.imageshack.us/img828/9986/idead.png
The basic idea is that you bind a control to your data and provide GUI controls to allow users to add/edit/delete records. Once the records are modified you re-bind the control to see the changes.
Take a look at the Databound controls in the .Net Framework. For a quick first pass you could use a ListView - a control which provides built-in functionality to automatically generate and mange the add/edit/delete GUI elements.
In 'real world' usage, storing big datasets isn't a great idea as more users = more sessions and each session uses server resources. You should really be getting/storing your data in a database or perhaps an XML file.
HTH

Dynamically load user control

I have this GridView that have it's DataSource as a list of previously selected products.
For every item on it, I need to Eval it's ID and load a specifc form that the user must fill, then after that i've got to update the GridView.
I have made those specific forms as User Controls, is this the best approach for this scenario?
If yes, how can I dynamically load them, in a way that I can make queries/postbacks then update back my gridview?
What you want to develop is called Master/Detail view.
It is described for example in http://www.asp.net/data-access/tutorials/master-detail-using-a-selectable-master-gridview-with-a-details-detailview-cs .
The only difference that as Detail you need use FormView, where on some initialization event (like DataBound http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basedataboundcontrol.databound.aspx )you need to dynamically create you control and set its parent to current template of FormView

Categories