Using ASP.NET 3.5's ListView and DataPager Controls: Sorting Data with the ListView Control 16 Jan 2008 00:00 GMT
When binding data to a GridView using a data source control, enabling sorting is as simple as ticking the "Enable Sorting" checkbox in the GridView's
Smart Tag. Enabling sorting turns each GridView column's header into a LinkButton that, when clicked, causes a postback and re-binds the data to
the GridView, sorting it by the clicked column.
Likewise, enabling sorting in the ListView is a fairly simple and straightforward process and can be accomplished without writing a line of code.
The main challenge with enabling sorting in the ListView control is that there are no pre-defined columns, like with the GridView. Therefore, we are on
the hook for defining and implementing the sorting interface. But once this is setup, the ListView can internally handle the sorting logic without the
need for us to write any additional code. Of course, in more advanced scenarios we may need to manually sort the data or programmatically specify the
sort expression used to internally sort the data. Prior to sorting, the ListView raises its Sorting event handler, which is an ideal place
to add any additional sort-related logic. Moreover, the ListView control's sorting logic can be programmatically invoked via its Sort method.
In this article we will look at how to enabling sorting in the ListView control. We will look at using the ListView's simple, baked in sorting functionality.
Following that, we will see how to programmatically invoke this sorting logic via the Sort method as well as more advanced scenarios. Read
on to learn more!
Read More >
Source: 4GuysFromRolla Two Common Pitfalls When Submitting a Web Form Using the Enter Key 09 Jan 2008 00:00 GMT
When filling out a form on a web page you have probably experienced the fact that if you hit enter when typing in a single-line textbox the form is
submitted. This is a feature that browsers provide to make it possible to submit a form without having to touch the mouse. For example, when visiting
Google's homepage focus is immediately set to the search textbox and, after typing in your query, you can hit Enter to submit the form and see the results.
Since it is the browser that submits the form when the Enter key is pressed, you might think that as an ASP.NET developer you do not have to worry
about this functionality. Just create a Web Form, like always, and the user can optionally use the Enter key to submit the form. Unfortunately, the life
of an ASP.NET developer is never that simple! There are two cases where the user hitting Enter doesn't result in the desired behavior. The first case
involves a page with multiple Submit buttons. Hitting Enter has the effect of submitting the form using the first Submit button on the page, although
you may mean for a different button to have caused the submit (because you want its Click event handler to execute). The second case involves
hitting Enter in a form with only one form field when using Internet Explorer.
In this article we will examine these two cases in detail and look at simple workarounds. Read on to learn more!
Read More >
Source: 4GuysFromRolla Windows Workflow Foundation Essentials 07 Jan 2008 20:29 GMTApplications that contain business processes and rules can benefit immediately from Windows Workflow's diagrams, class libraries, runtime, rules engine, and customization capabilities.
Source: DevX Using ASP.NET 3.5's ListView and DataPager Controls: Grouping Data with the ListView Control 02 Jan 2008 00:00 GMT
ASP.NET version 3.5 added two new data Web controls to the Toolbox: the ListView and DataPager. As discussed in the first installment of this article
series, Displaying Data with the ListView, the ListView control offers the same
built-in features found in the GridView, but much finer control over the rendered output. The ListView's output is defined using a variety of templates,
and we looked at examples using the control's LayoutTemplate and ItemTemplates. In particular, these examples used a LayoutTemplate that included a
placeholder for the ItemTemplate's rendered output.
The ItemTemplate is rendered for each record bound to the ListView control, and is typically referenced in the LayoutTemplate. This approach generates
the rendered markup defined in the LayoutTemplate, plus the rendered markup created by the ItemTemplate for each record. This works fine for simple
rendering scenarios, but in more complex scenarios we may need to render different formatting markup for different groups of records.
For example, imagine that we needed to display a set of records in a three-column HTML <table>. For each record we would want to
emit a table cell (<td>), but for every three records we would need to emit a new table row (<tr>).
Such customizations can be accomplished declaratively with the ListView control's includes GroupTemplate and GroupItemCount properties.
In this article we will see how to use the GroupTemplate and GroupItemCount properties to instruct the ListView control to render
different encasing markup for every n records. We will look at two demos: one that renders records into a series of ordered lists, and
another that illustrates how to display data in a multi-column table. Read on to learn more!
Read More >
Source: 4GuysFromRolla