Posts

Showing posts from November, 2010

Creating an SSRS report with dynamic columns

Image
A couple years ago, I created a report in SQL Server Reporting Services that allowed the columns in the report to be configured dynamically to display different datapoints. The report allows the user to configure a parameter for each column to determine what datapoint is shown in that column. This approach is too unwieldy for a report accessed by the user directly, but can be handy if the report is distributed by a subscription. In this way, multiple users can get the same report configured to their needs. If you have a large number of users, this approach is much faster & more maintainable than creating separate reports for each one. Disclaimer, this was done in Visual Studio 2005 against a SQL Server 2005 DB so things may have changed a bit. First, I defined the SQL query. Notice that there are "Aggregation Type" columns returned which reference some of the actual data columns. This tells the report how to aggregate that particular column. So, for example if

Adding javascript hover event for items in an ASP.NET dropdownlist tied to a CascadingDropDown

I recently had a user ask if I could load some information onto a page in our application when he hovered over an item in an ASP.NET dropdownlist. To complicate matters, the dropdownlist was grouped with two others controlled by a CascadingDropDown control from the MS AjaxControlToolkit. So, the items in the dropdownlists were databound from the client-side. Though I'm not completely happy with it, I did manage to get something going and decided it may be useful to someone else. First, here's the definition for my dropdownlist. Second, I defined a method to handle the dropdownlist's "populated" event (Remember, it is populated client-side by the CascadingDropDown control). It loops through each of the items in the dropdownlist & assigns each an onmouseover event. function pageLoad() { $find("QuicklistWorkorders").add_populated(OnWorkordersPopulated); } function OnWorkordersPopulated() { var ddl = document.getElementById("<

Making a standard ASP.NET listbox do multiselect without holding Ctrl

I've always hated that users of a standard ASP.NET listbox control must hold ctrl to select multiple items. It's just a recipe for bad/incomplete data input. So, I set out to see if I could make the listbox do multiselect without holding the ctrl key. I know that there are third party controls out there that accomplish this more elegantly, but I wanted to see if it was possible with a standard control. I managed to get it going with some javascript help. First, I defined my listbox & gave it an onclick event to fire a javascript method: Second, I created the javascript method (the last one below) to loop through the listbox elements, select all of the items previously selected, and toggle the one the user clicked. //This array holds the "selected" state of each listbox item var selectedClientPermissions = []; //Because I'm working with a databound listbox, I grab the selected values //on page load & put them in the array. function pageLoad() {

Creating a simple Context Menu on a databound ASP.NET treeview

Recently, I was in need of a right-click context menu for the ASP.NET treeview control.  I know there are many third party & open source treeview controls that have this functionality built-in, but my situation demanded that I build my own.  After much Googling, I found that most of the posted code for creating your own is complicated at best.  So, having the MS AjaxControlToolkit already in heavy use on the project, I decided to utilize it.  Here's what I came up with: I first created a menu in an asp:Panel & added a popupControlExtender from the MS AJAX Control Toolkit: New Folder Upload File Delete Folder Adjust Permissions I then added the following attribute to the asp:TreeView tag: oncontextmenu="ShowTreeviewContextMenu(this, event); Finally, I created a javascript method to handle the treeview event & display the popup in the proper place: function ShowTreeviewContextMenu(sender, menuEvent) { var selectedNode = event.srcElem