I use Asp.net 4 and C#.
I'm developing a simple CMS, at the moment I want to displays the content for a specific PAGE (Title, BodyContent, and some other fields) at the end user on a web page (like as this website display its questions to its Users).
I need wrap my fields from database in appropriate HTML TAGS example <h1>Title</h1> <div>BodyContent</div>.
The resulting page should be READ ONLY .
I would like to know:
If a ListView web control with setting for a single row would be the
right choice (maybe binded with ObjectDataSource).
If would be better use separate Web Controls like Literals or
Labels to displays my fields sparsely on my webpage
In case of previous point how would I DataBind every single Control? Using different DataBinder or maybe with Linq an projecting using Anonymous Type.
I'm mainly concerned with read-only performance.
If you have data that's a single row, there's not much point in using a ListView. They're designed for showing lists of data (hence the name). If you have one item, consider either a DetailsView or single Labels.
If you have a particular class that often needs to be displayed in a certain way, consider setting up a Web User Control that can be bound to instances of that class.
Related
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.
I'm writing a small program that lets the user enter a keyword. The program then searches through a database table and finds all records (using LINQ) that match the user's search criteria.
The resulting records that are returned will be displayed on the screen as images (much like Googles image search page). The user will then be able to click on any of the returned images and be taken to a page with more detail about that image.
My question is, what is the best control to use to display the images that result from the user's initial search? This is an ASP.Net program. Would it be better to show the images in a gridview? Or a listview? Or build a table and fill each cell with an image button? I've never done this before so I'm basically just wondering how to present the data.
I'm not looking for code but I'd love to hear how you'd handle this.
Thanks!
EDIT:
I should add that all the images are the same size and I'm thinking that I'd return all images and let the user scroll down the page. Realistically, I don't think there would ever be more than 50 images for the user to choose from. I'm envisioning having five images on each row of results returned, like the below image:
I've always been a fan of keeping things simple by using a Repeater where I can. You'll have more control over how things will look writing for own HTML.
Since you're using images, and I assume they will be in different sizes, I'd make the Itemtemplate contain a div with an anchor and img inside of it. Slap a max width onto the images and hide the overflow on the div so the images don't look scrunched.
Just set the datasource property of what's returned from the filter, call a databind() and you're good to go.
That's how I'd approach this situation. I too am interested in hearing from others for comparison.
I'd go for the trusty Repeater control. That gives you the flexibility to render whatever you want for any collection.
I would create a control that builds a dynamic table control. You could have a List<string> to hold the url of each image. I would expose a public method called AddImage(string imageUrl) that would add the url to the List<string> collection.
Once the page is ready to be rendered, I would divide the number of images you have by 5 (this will give you the number of rows you need) and then just render the table. In addition, before rendering, you could use LINQ to get the data before render (for example, to sort it)
I have an asp.net webforms site with a rather large GridView. The GridView is rendered from a filtered list of data objects.
Some of the data objects have children of the same type.
In my GridView, I'm initially only showing the parent objects. I want to be able to expand the parent to show the child objects, via an Ajax call, and insert the new rows under the parent.
The catch is, they need to follow the same formatting and rendering rules as the parent, and fit in with all the rest of the existing rows. This means that all columns of the new child needs to fit in the columns of the rest of the rendered grid.
I would also like to re-use the existing GridView rendering methods if possible, so I don't have to maintain duplicate code that essentially does the same thing.
I can easily use the DynamicPopulateExtender from the AjaxControlToolkit to call a web service to get the child rows, but that wouldn't easily give me the rendered and formatted HTML that would fit into the already rendered GridView table.
Is there a way to get this to work properly, or is there a different way I should approach this?
Make your Ajax calls and insert the data with jQuery perhaps using a templating engine like jsRender to merge the data. Use the same css classes for the gridview and template to keep the uniform look you want.
I have created a databinding treeview which binds with multiple tables and display hierarchical data. I stole much of the mechanism from http://www.codeproject.com/KB/tree/dbTree.aspx if it interests you.
I first merge(outer join) all the datatables into a big datatable, then databind the treeview and bunch of textboxes to the big table. User can click on a node in the treeview and see corresponding info in the textboxes. So viewing part is nice.
Now coming to updating, deleting, adding info via textboxes entries, is there a way the user can make changes via the textboxes, and immediately reflected in the big table and individual tables ?
Thanks!!
You are joining information in a kind of view and I understand that this view is stored in memory while you fill your tree. So, if you do any kind of change in the data inside the tables that composes your view, you must reload it.
If you are working with an web app, it is going to be something natural, because each user interaction will do a new request to create you view.
Currently, I'm in the process of making a custom solution for invoicing. I have created multiple ways for customers to create their template (HTML, Word, LaTex) and get invoices according to their template. However, these invoices are party manually generated.
So, the process is:
Request to create a new invoice
An preliminary invoice is created
The user gets a chance to make changes (i.e. add, remove, change rows)
Create a pdf
Just to be clear, the preliminary invoice does not need to be formatted as the template is, but you should be able to add/remove/change rows and for every cell, indicate whether the value should be visible in the final result.
My problem is that i cannot find a suitable way to display the preliminary invoices. I tried a datagrid (default, telerik, devexpress), but it's too messy. Besides a datagrid, i have no idea what i can use.
What controls can i use best to have a nice and usable UI.
Please don't be like this:
alt text http://bitsandpieces.us/wp-content/uploads/2008/03/imagesapple-20google-20and-20you.png
A typical UI paradigm for this kind of thing is to view it as two separate problems: giving the user a way of viewing the elements that he can modify, and giving him the ability to modify any specific element. You use a list control (ListBox, ListView, maybe TreeView if the elements are organized hierarchically or need to be grouped into categories) to present the elements, and then when the user selects an element the program presents a tabular presentation of field names and editable value controls.
Basically, you're dividing the program's functionality into two categories: stuff that the user wants to do to rows (add, remove, re-order, select) and stuff that the user wants to do to the selected row's elements.
You can mush these two sets of functionality into one if you use a DataGridView, but as you've seen that gets pretty ugly if there's any complexity to the elements you're editing.
Two possible approaches to this: the property-sheet paradigm (select object, right-click, select "Properties", edit values in a modal dialog), or a paradigm where the window's split into two panels, with one being the rows and the other being the details of the currently selected row. There are lots of others.
What is your platform? Winforms? WPF?
What exactly did you dislike about using a datagrid for this? Part of the problem is that whether you like it or not, you're going to be coding a datagrid - you essentially described features of one. If at all possible try to use someone else's datagrid because it will save you a lot of work. Typically, 3rd party datagrids should be fairly customizable, and you should be able to make it look however you want - and take advantage of the built in sorting, editing, grouping, etc. Creating a datagrid-like control from scratch isn't easy and should be avoided if possible.
You don't have to have a plain giant datagrid - you can crate a custom control that displays the invoice formatted however you like, with a live datagrid appearing only where the invoice shows tabular data, formatted to appear as an integral part of the invoice itself.
I'm doing something similar, where the client can edit or even remove the line items for the invoice prior to sending it to the client.
The current app they run their business on is a WebForms Intranet application, so this is an extension to that. So they can add/remove/edit rows fairly easily.
But Egor is right. You're essentially talking about a datagrid no matter what you do. I take it you want something 'cleaner' and more intuitive?
Simplicity is difficult.
I would take a look at what is already out there, especially for invoices, and see how they are doing it.
Not sure how big your company is, but it never hurts to take advantage of the large company applications and user interfaces, the pour thousands/millions of dollars into user interface design and testing.
I would take a look at any of the following (most offer a free trial, or just try searching for screenshots):
www.freshbooks.com
www.invoicera.com
www.getcashboard.com
www.simplifythis.com
Just some ideas ... hope this helps!