I have a listview that is connected to a datasource. When I view the project in a browser, the listview is populated with data from the Northwind database. I just have the CustomerID and ContactTitle columns displayed. I want to be able to click on the CustomerID and then display the rest of the information about that particular customer. I've searched and searched and searched and tried a ton of different things but I just can't figure out how to make the CustomerID clickable. I am using c# and ASP.NET. Any help would be greatly appreciated.
You want to create a itemTemplate that contains various controls and bind the columns of your datasource to those controls. For the field in question you want to make sure you select a "clickable" control. like a link, button or even a div, and then create a handler for that click event. A good example of such a thing can be found in MSDN here: http://msdn.microsoft.com/en-us/magazine/cc337898.aspx
Do your list items contain li's? Whatever tag you use, you would use the javascript onclick event on each li to initiate whatever action you require.
If you need to retrieve customer data you could initiate a postback from your javascript to retrieve the data and display the customer details.
Related
I'm trying to figure out what design object to use for my forms application.
I want to make a forms application that looks like below image.
I have so far used splitcontainers for the layout and three gridviews with separate DataSources querying the same table but with different where clause for eatch gridview. This works fine but when i click a row in any of the three gridviews i cant have that data show on the right side becaus i can only get data from one datasource on my labels and textfields etc.
I guess that i should use one datasource but in some way have different where clause to each gridview but i've tried it and i only end up with the same data in all of the gridviews.
If it's to complicated to get together i would instead have a new form window apeare with a click of a button. So if i select one row in any of the gridviews and then click edit a new forms window will open for me to edit data in. How can i do that?
Please advice me how i should try to build the application.
For example; Dont use gridviews use this or that instead. Dont use splitcontainers use this instad. Use bindingsources... etc.
I really appreciate any help you can provide
I have a page with around 20+ controls. Within this page I have a partial View which I am using to create an editable grid. This grid has Add New Row/Remove Row buttons on click of which data entered in the textboxes in grid row gets added to the grid.
Whenever I click these 2 buttons, my page is getting refreshed due to which whatever data is being entered by the user in the 20+ controls of main page is lost.
I have tried hopelessly searching for solutions quite some time, but still trying my luck out here. Any ideas are appreciated.
Well I recommend you to use full jquery mechanisms to add or remove rows. You can easily add or remove HTML elements. All you have to care about is to maintain the numbering system. I suggest you to use a view model that contains a list of objects that you need to add or remove. At first render it normally by providing list of objects (from database or other source, if required). After this define your add and remove buttons to type button and play with jquery to add remove table rows or even divs. After adding or removing required element, reorganize your numbering. At submit you can use either full postback or ajax postback. If Any confusion, let me know.
Here's my problem. I am trying to add usercontrols dynamically to different rows of a GridView.
Let me explain the scenario further. Let's say, I have a page where the user can place orders for different kinds of items. The order form for each item is different in layout and code, and has its own usercontrol. There is an "Add More" button, which lets the user add an extra row to the GridView, while the kind of form that gets appended is selected by the dropdown list (see picture below).
What I am trying to do is - have a separate UserControl for each one of these forms, and then have the UserControl added (or maybe I should say "bound") to the GridView. Every time a new row is added, I plan to re-bind the GridView, including rows from above, to maintain all the rows.
The problem is - the main page cannot know what fields there will be inside each individual UserControl (they can be anything, really, and down the road, newer UCs could be added). So my main question is - how do I bind the data to the GridView, when I do not know what to bind? Is there any way to bind the data from inside each UserControl itself?
I hope my problem and question are clear enough. Thanks for helping.
We have a list of elements we use to drive a form view. Typically the resultset is between 5-15 records. Right now in the form view we have the typical first/prior/next/last for navigation. The problem is that sometimes the user needs to go directly to a specific record to edit it. The records here are job tasks that have some pretty short descriptions.
The idea was proposed to put a gridview inside of the formview that lists all of the records for that form, and a user can just select view or edit on that record and it will navigate directly to that record and put it into the proper mode. We could put this outside the form view as well, that doesn't really matter.
The question is, regardless of the dirving force, how to I tell the formview to go to record X driven from something like an external grid.
I know that the formview has the DataKeyNames field but is there a way to say "Go to record who's PK is 17" given that it's in the current dataset for the formview?
If so, does anyone have any sample C# code for it? I know we could just populate the existing formview with a single record, but we also want to keep the normal navigation buttons in place as well, in the event as well (sometimes there's cases where there's hundreds of job tasks, in which case we'd supress the grid view -- sounds wrong but there's more to the business case).
This short solution was to embed the grid in the FormView ItemTemplate and reference the same data source for both.
To made the row editable, you need a simple callback for RowDataBound on the grid in which you will retrive the link button (or whatever control you're using to trigger the edit) and then set the command argument to the rowindex. After that, you need to have the callback for the link button (or trigger) that wil retrieve the command argument (again the row index) and then set the FormView PageIndex to that value, and then set the ChangeMode for the FormView to FormViewMode.Edit.
So to recap, for read only view it's a grid with all of the items, but when handle the edit or insert, you get the traditional form view.
My current situation is to display an unknown number of Plantypes and within those Plantypes display a list of Participants(also unknown number), the participants have a textbox and a dropdown that is editable (you can't edit the individual rows, there is one update that does a bit of validation then updates all rows.)
I currently have a gridview nested withing a repeater, the repeater displays the Plan in a label and OnItemDataBound I call a method to populate the gridviews. It looks great, but I can't figure out how to save all the data at once. I'm not opposed to handling this a different way, as in loose the gridview and or repeater, if someone has a better idea.
This is C# and framework 2.0...there is no sorting or paging on the gridviews...just some links and the fields to update.
thanks in advance,
Padawan
HTTP is stateless. Since a user physically can only update one record at a time you should implement some way to save as the user goes. This can be a simple as having a row focus and row blur events and do the saves using AJAX on blur(unfocus). Maybe make is modal as they edit so they cannot leave the page without saving.