Tag | GridView Posts

I was trying format my dropdown list to should the decimal numbers as pecentange. But the MSDN article is not completed. It turned out that {0:P2} is what I'm looking for. Here is the full list regarding the string format: Data Formatting for DataTextFormatString Format String Description {0:Cn} Currency. Displays numeric values in currency format with a leading dollar sign; n indicates the number of decimal places. If n is omitted, the default currency precision is two decimal digits. {0:Dn} Decimal. ...
Our application shows custom HTML confirm message box, that we wanted to locate in the middle of the browser window. If I would start from the scratch, I would use Ajax Control Toolkit ModalPopup However, because the proprietary code to show div has been already written, I wanted just to set vertical position of the div. I've created a function based on code from AlwaysVisibleControlExtende... Initially it didn't work, because common.JS getClientBounds : function() returned 0 clientHeight and clientWidth. ...
The other night at our local development group, the Charlotte based Enterprise Developers Guild, Brian Hitney from Microsoft gave and Overview of Microsoft ASP.NET MVC. This is my first time seeing the MVC pattern from Microsoft. This is the take away Items from this talk which may be helpful to those that are new to the MVC concept. Routing Before discussing the structure of the MVC pattern, it is important to understand how pages are routed through the MVC. Using a Routing table, links are directed ...
Recently I needed to create a CustomValidator inside a GridView. In the end this was relatively straight forward, however I had some problems in my main application. As I could not find any examples of this on the Internet, I am documenting this here. As a proof of concept I created a web page with an UpdatePanel containing a ValidationSummary, a simple GridView and a button. The GridView was populated by an XMLDataSource (for simplicity), and a column template containing two text boxes and a custom ...
A solution to the EmptyDataTemplate problem: how to insert via GridView when table is empty. This is Oracle-based and does not use a SqlDataSource. If you have worked with the GridView feature for any length of time, then you probably have had to address the "EmptyDataTemplate" situation, where there are no records in the table from which you are pulling. Here is a sample screen shot of the typical solution when the table is empty. This solution will work, although it is not too elegant. Also, it ...
Here is how you can add a database value to the URL of a HyperLink that is in a GridView. In this example the text displayed is the same as the value added to the URL. Also the data is bound through a SqlDataSource and the “ID” value is from the output of the Select statement the SqlDataSource uses. This is a quick way to put the data in the URL without using any code in the code behind. <asp:TemplateField HeaderText="ID" > <ItemTemplate> <asp:HyperLink ID="hlID" runat="server" Text='<%# ...
OK, here is a nice chunk of code for a web part that will display the accounts within a Forms Based Authentication database. The code is complete all the bells and whistles including a context menu, paging, sorting, and searching. I couldn't get filtering to work so I opted for searching instead. It turns out searching will be a much more beneficial feature because selecting a username to filter on from a list of several hundred items would be pretty inefficient. This code should pretty much plug ...
Biding one GridView with Different tables from the database based on user selection By: Vincent Maverick Durano This article demonstrates on how are we going to bind a GridView with different data from different tables based from the selection in the RadioButonList.. In-order to achieve this functionality then we need to dynamically generates a boundfield columns because the GridView will have different datafields to display. Also note that Im using the Northwind database here just for demo. STEP ...
In developing one of our new applications I ran into an interesting issue with the DataGridView, which contained a DropDown (ComboBox) column that was bound to a different BindingSource. The basic issue is that the user would click a LinkButton and select a file. That process would create a new instance of an object on the backend, which would be added to a list that was then bound to the DataGridView. The drop down option on this new item would be left null however. When the user would go to click ...
The following code below enables you to read the response from MOSS List Web Service... MOSSListWS.Lists list_svc = new MOSSListWS.Lists(); list_svc.Credentials = new System.Net.NetworkCredentia... // The URL property for WebService retrieve list_svc.Url = "http://ilocalhost/_vti_bin... XmlNode itemCollection = list_svc.GetListItems("list... string.Empty, null, null, "0", null, ""); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(itemCollecti... DataSet ...
I’ve been recently using LinqToSQL with a current project and finally got down to business where I needed to work with fields from multiple tables. LinqToSQL is nice, but it does have it’s drawback that it maps objects directly to the schema. Fortunately, it maps their relationships too. Let’s avoid the discussion of LinqToSQL pros and cons for now and figure out handling multi-table fields. Did I mention I’m using the LinqDataSource? Oops… that too. I’m not a fan of the built in sqldatasource and ...
I've had a few people ask me about my custom GridView and whether I can help them with theirs. Though, I cannot share my code directly, I can provide some guidelines. In the coming weeks I plan to post segments stepping through customizing a GridView. My customizations are by no means perfect, and I have had to tweak things as I encounter issues. I look forward to sharing my experiences. I will probably post a multi-part article that walks through customizing a GridView. Again, I will not be posting ...
You may run into this error when trying to use the new DataPager control with a GridView or any other control, other than the ListView control. For a moment I couldn't believe that the DataPager cannot work with the GridView control. Then after a few moments of research found out that, the Data Pager control requires the Data Control to implement the "IPageableItemContainer" interface. This is a part of the System.Web.Extensions namespace that is shipped with .NET 3.5. This interface is currently ...
If you have the requirement to make your website accessible, unless you were given that requirement before you began the project, you will probably be converting an existing site. This was my task. After a lot of research, some work with blind users, and working with JAWS myself, here are the recommendations that I am presenting to our development team to make our ASP.NET 2.0 application more accessible. In another post, I will give some more detail about some of the specific solutions we developed. ...
Matt Berseth wrote a very interesting article on “Bulk Inserting Data Using the ListView Control". The idea is to give the user an Excel like interface where they can edit the rows with custom data and finally click the update button to persist the data in the database. Matt’s solution was great but lacks a very important detail. There was no way to know what rows were changed by the user. Matt took the road to update all the rows whether they were changed or not. In this article we are going to ...
Mark Berseth wrote a very interested article about Bulk Insert Data Using ListView Control. Basically, the ListView control is displayed with the TextBox controls in each row (like MS Excel). Now, the user can write in the TextBox and then use the submit button to insert all the new rows to the database. This works well when you are inserting the data into the database. The problem starts when you try to update the data which is already in the database. Let's say you populate the ListView with some ...

I have just published an article on GridViewGuy. The article talks about the JQuery API and how you can use it in your application. Check out the link below:

A Look into JQuery API

Here we go for starters. ;) The following C# code will allow you to persist AutoPostback DropDownList values on an ASP.Net page, without the use of an AJAX partial page update or a database. It simply uses session variables to persist the values which would otherwise be lost upon navigating away from and back to a page or by redirecting the browser to itself to refresh a databound control, such as a GridView. This was a problem for me on a page that contained three DropDownLists, each of which was ...
Selecting checkboxes inside the GridView control is a very common operation and that is why I have several articles and videos dedicated to this subject. Selecting CheckBoxes Inside GridView With a Twist VIDEO: Selecting CheckBoxes Inside GridView Recently, I was playing around with JQuery library and thought of implementing the same scenario using the library. Here is the code used to perform the SelectAll and DeSelectAll function. <script language="javascript" type="text/javascript"> $(document).ready(function() ...
This article describes on how to add rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in the TextBox on Button Click and retain the GridView data on post back. STEP 1: Add One TextBox, One Button and One GridView control the web form. The ASPX mark-up should look like these below <asp:TextBox ID="TextBox1" runat="server"/> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> <asp:GridView ...
This article describes on how to add multiple columns and rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in each TextBoxes on Button Click and retain the GridView data on post back. STEP 1: Add Three TextBox, One Button and One GridView control the web form. The ASPX mark-up should look like these below <asp:TextBox ID="TextBox1" runat="server"/> <asp:TextBox ID="TextBox2" runat="server"/> <asp:TextBox ID="TextBox3" ...

I have just published an article on www.gridviewguy.com. The article explores the workings of URL Rewriting mechanism using RewritePath. You can check out the article using the link below:

Url Rewriting Using RewritePath

A WPF ListView is a possible replacement for a datagrid, when it doesn't have to support advanced features like grouping or filtering of rows. If you use a ListView in your WPF application, and set the "View" property of this ListView to be a GridView. A ListView/GridView even supports features like reordering and resizing columns. Unfortunately, it is not possible to define a minimum or maximum width for the columns. Fortunately, it is not really to do this in the code behind. Let's see how. First ...
I've created the GridView with templates like the following: <asp:TemplateField SortExpression="Date1"> <AlternatingItemTemplate... <asp:CheckBox ID="chkSelected" runat="server" /> </AlternatingItemTemplat... </asp:TemplateField> <asp:TemplateField SortExpression="Date2"> <AlternatingItemTemplate... <asp:CheckBox ID="chkSelected" runat="server" /> </AlternatingItemTemplat... </asp:TemplateField> On runtime it cause the error: Message : Multiple ...

I just published a new podcast on www.gridviewguy.com. In the podcast I talk about the new ASP.NET MVC Framework. You can download the podcast using the link below:

Introduction to the ASP.NET MVC Framework

Over the last few weeks of working with, and developing an ASP.NET application for, use with JAWS, I've found a few JAWS keystrokes to be particularly helpful. (For those unfamiliar with JAWS, it is the industry-leading screen reader software for those with visual disabilities.) The Control key. I call this the "shut up" button. It stops JAWS from reading. After a while you'll find yourself using it a lot. Insert + Down arrow. This causes JAWS to begin reading at the current JAWS cursor position. ...

I just published an article on www.gridviewguy.com. The article demonstrates how to create simple bar charts using the graphics API provided by the .NET API. You can check out the article using the following link:

Creating Bar Charts Using .NET Graphics API

I always wanted to play around with the graphics API included in the .NET framework. So, I decided to create simple application that creates bar graph using the data supplied. In the past, I have used the WebChart control to fulfill my graphics needs. You can check out the article here. The first task is to create a class that will hold the data from which the graph is plotted. The class is called ExamData class. public class ExamData { private double _score; private string _name; public double Score ...
This is not a complete list of the accessibilty features available with a GridView, but this is what we're doing to make ours more accessible. (Note: At this point, we are primarily focused on users who use JAWS.) UseAccessibleHeader="true" Property of the GridView itself When the GridView is rendered as a table, using this property formats the header (first row) of the table using <th> tags instead of <td> tags. When navigating through the table with JAWS, the column header is announced ...

I just published a new article on www.gridviewguy.com which explains how to run unit tests using the Post-Build option in Visual Studio. You can check out the article using the link below:

Using Post-Build Event to Execute Unit Tests

C# Excel Export from ASP.NET Page ----------------- --web Page - ExcelExport.aspx ----------------- <%@ Page Language="C#" MasterPageFile="~/MasterPag... AutoEventWireup="true" CodeFile="ExcelExport.aspx.cs" Inherits="Forms_Techniques_... Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="Conte... Runat="Server"> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> <br /> <asp:LinkButton ID="LinkButton1" runat="server" ...
A major upgrade to the ASP.NET Dynamic Data was released on April 8th, 2008. This release is named ASP.NET Dynamic Data Preview. ASP.NET Dynamic Data allows you to automatically render fully functional data entry and reporting pages that are dynamically constructed from your ORM data model meta-data (LINQ to SQL or LINQ to Entities object model). In addition to supporting a dynamic rendering mode, it also allows you to optionally override and customize any of the view templates using any HTML or ...

I managed to get some time today and recoded all the demos that I presented in Houston .NET User Group meeting. You can download the samples using the link below:

[Download Demo]

I 've created GridView with HyperlLinkField columns. But I wanted to have link click to postback to the same page. I looked at some solutions like in a thread:GridView HyperLinkField with call to a javascript function It seems not working, I have a link as : <asp:HyperLinkField DataTextField="Field1" HeaderText="ID" SortExpression="Field1" NavigateUrl="javascript:ret... datanavigateurlfields="Fiel... target="_top"/> One of possible approaches described in Steps to ...

Ahh!! I am tired of these Microsoft Visual Studio bugs!! I am using GridView with SQLDataSource control and I cannot find the automatic edit, update and delete events. Check out the screen shot below:

where_is_my_edit_and_update

Below is the solution <asp:GridView ID="gvSubject" runat="server" > <Columns> <asp:HyperLinkField DataTextField="CategoryName" DataNavigateUrlFields="Subj... DataNavigateUrlFormatString... /> </Columns> </asp:GridView> ...
Nice Link

http://www.codeproject.com/KB/aspnet/GridViewCrossPagePostBack.aspx

GridViewGuy podcasts are now available on Feedburner. Simply, subscribe to the podcasts using the link below:

http://feeds.feedburner.com/GridViewGuyPodcasts

Thanks,

I have just published a new podcast on www.GridViewGuy.com. In this podcast I talk about advantages of code coverage and how it can help to develop better application with lesser bugs. You can check out the podcast using the link below:

http://www.gridviewguy.com/ArticleDetails.aspx?articleID=394_Introduction_to_Code_Coverage

I've have been pretty quiet lately. Actually, I've been quite busy and it turns out that there isn't much new to share. However, this is one thing that comes to mind. A recurring pattern in my UI is selection criteria that can applied to a GridView. It turns out that frequently the same criteria applies to various screens. I use LinqDataSources to bind to DropDownLists for many of the criteria. It is not uncommon to use one controller for every page. Following this approach, I ended up with the same ...

In this podcast Mohammad Azam will introduce the concepts of Test Driven Development. He will also talk about testing tools and code coverage and how test driven development enhances the application design.

Podcast: Introduction to Test Driven Development

If you are an ASP.NET developer or want to become one, there are numerous books available that talk about the ASP.NET framework and/or how to build web sites using ASP.NET. Pact Publishing has a book that focuses specifically on the data presentation controls that are available in ASP.NET, including ASP.NET 3.5 called ASP.NET Data Presentation Controls Essentials by Joydip Kanjilal. The book provides a good introduction to the basics of how data binding in ASP.NET works and then expands on that introduction ...
Couple of days back I wrote an article Designing Application Using Test Driven Development in which I explained how test driven development can help us design better solutions. I just posted second part of the article in which I explained how test helps us when we change the code. You can check out the article using the link below: Designing Application Using Test Driven Development Part 2 ...
Prior to utilizing Ajax making a page with tabs was a bit of a pain. I would setup a MultiView and add in Views for each tab. Ajax’s Tab Container control is much easier to use. I’ve listed below the order on a sample aspx file that I setup the various Ajax controls to get it all to work. The only real tricks I saw were to add the ScriptManager and the order of the TabContainer/TabPanel/Conte... The ScriptManager and Tab controls went inside the <div> and I made sure that the toolkit ...
In a recent post, I mentioned that I was working on a customized grid view. Last week I completed the "binding to user settings" behavior. Then I took a look at the source and was stunned. I had almost 700 lines of code (and comments) and it wasn't well organized. So, I set out to start adding regions to the code to separate different behavior. The last sentence should have raised some flags. Regions to separate behavior? What happened to the cohesion of my grid view? I seem to have lost sight of ...
Location This month's (and possibly future) meeting will be held at Benefit Focus on Daniel Island. If you ever attended the past meetings at Blackbaud, you probably remember passing Benefit Focus on the way there. If you need directions follow this link from Benefit Focus: http://www.benefitfocus.com... Register Please! Let us know you're coming! Please RSVP at EventBrite: http://march-gcnug.eventbri... Topic The Mole Visualizer For Visual Studio has taken the developer ...

I just posted a new article on www.GridViewGuy.com. The article discusses how test driven development evovles the design of the application. You can read the article using the link below:

Designing Application Using Test Driven Development

Wanna see something neat? Create an ASPX page in Visual Studio and add a GridView Control. Leave the name as GridView1. (You can do this any number of ways, but I happened to do it in an aspx page.) In your codebehind page, add the following to the form.Load event: Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load Dim filter As String = "System" Dim query = From a In AppDomain.CurrentDomain.Get... _ Where a.GetName().Name.Contains(f... _ ...

In this video Mohammad Azam will demonstrate how to use Grouping using LINQ to SQL classes.

Check out the video using the link below:

LINQ to SQL Grouping

I wanted to have multiple checkboxes in GridView . Below are a few links, that I've read before implemented my user control. Checking All CheckBoxes in a GridView Using Client-Side Script and a Check All CheckBox Storing and Maintaining DataGrid CheckBox Values - Selecting, Confirming & Deleting Multiple Checkbox Items In A DataGrid/GridView Implementing ITemplate as Anonymous Method Creating Web Server Control Templates Dynamically by implementing the ITemplate interface e.g. CheckBoxTemplate ...