Tag | GridView Posts

If you like to migrate your Web tier or the ASP.NET Application to Windows Azure, check my new posts Part I and Part II SQL Azure is the latest buzz around Cloud Computing and the ability to take relational database to the cloud as is, is something most would welcome compared to the earlier model of ACE (Authority, Container, Entity) that was there when SQL Azure was SSDS. Well, like others, I also got interested and wanted to explore the SQL Azure. SQL Azure is currently in CTP and offers token ...
In this Issue: Jesse Liberty, Jonathan van de Veen, Alex Golesh, Chris Cavanagh, Michael Washington, Danijel Stulic, Bob Bartholomay, Mark Tucker, Chris Klug, and Lee. Shoutouts: Jeff Handley has another poll that he'd like you to take a shot at: Should DomainDataSource.AutoLoad be True or False by default? Walt Ritscher has announced that Shazzam development is moving again... check it out if you haven't already and stay tuned for enhancements! Steve Commisso has been hard at work and has reported ...
It's a shame that the DataGridViewTextBoxColumn class doesn't allow you to set the casing so that you can restrict user input to all upper or lower case letters. Fortunately, it's actually pretty easy to create a custom column class to do just that. public class DataGridViewUpperCaseTextBo... : DataGridViewTextBoxColumn { public DataGridViewUpperCaseTextBo... : base() { CellTemplate = new DataGridViewUpperCaseTextBo... } } public class DataGridViewUpperCaseTextBo... : DataGridViewTextBoxCell ...
When I wrote the first post in this series, there was tremendous amount of interest generated and also a lot of feedback requesting to post some of the advanced features. Like I said earlier, ASP.NET 4.0 has lots of new features some of them as simple as Page.Title whereas so as big as caching improvements. This post covers one such feature which is Routing in Webforms. Although Routing was available even in .NET 3.5 SP1, (check this excellent post by Phil Haack on implementing Routing in ASP.NET ...
Here are some info on how to do an Autoscroll for your program controls TextBox autoscroll textBox1.SelectionStart = textBox1.Text.Length; textBox1.ScrollToCaret(); ListBox autoscroll listBox1.SelectedIndex = listBox1.Items.Count - 1; listBox1.SelectedIndex = -1; ListView autoscroll listView1.EnsureVisible(lis... - 1); TreeView autoscroll treeView1.Nodes[treeView1.N... - 1].EnsureVisible(); DataGridView autoscroll dataGridView1.FirstDisplaye... = dataGridView1.Rows[dataGrid... ...
(this is a repost since the initial post had a few issues that couldn’t be corrected) I am playing with the ASP.NET 4.0 QueryExtender released as a part of the Visual Studio 2010 Beta 1. It provides endless opportunities for working with data without writing much code and when you combine it with a few Ajax features, gives a truly great user experience with very less effort. To begin with you need the Visual Studio 2010 Beta 1 and .NET Framework 4.0 Beta 1. You can install both from http://msdn.microsoft.com/h... ...
In my previous post, I have posted the updated the codes about Adding Dynamic Rows in ASP.Net GridView Control with TextBoxes because there is a bug on that. So obviously the codes in my other example about Adding a Delete functionality in Dynamic TextBoxes in GridView is affected. To fix the issue then you can refer to this updated code below: protected void LinkButton1_Click(object sender, EventArgs e) { LinkButton lb = (LinkButton)sender; GridViewRow gvRow = (GridViewRow) lb.NamingContainer; int ...
Well its seems that there is a little bug with my previous article about “ Adding Dynamic Rows in ASP.Net GridView Control with TextBoxes “. The problem is that whenever you change the value of the previous data in the TextBox the updated values will not reflect on postbacks. So I have modified a bit of my codes at AddNewRowToGrid() and SetPreviousData() methods to fix the issue. Here are the code blocks below for the updates: private void AddNewRowToGrid() { int rowIndex = 0; if (ViewState["CurrentTable"] ...
In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I’m going to show on how to delete a certain row in the dynamic GridView with TextBoxes. Note: Before reading this example, then be sure to refer my previous examples mentioned above so that you will have a basic idea on how does the ...
In my previous example, we have learned on how to save the actual image to a folder and image path to the database. In this example, I’m going to show on how to display those images in a GridView and Repeater control. To get started, let’s create a method for fetching the image information from the database. Here’s the code block below: private DataTable GetData() { DataTable dt = new DataTable(); SqlConnection connection = new SqlConnection(GetConnection... try { connection.Open(); string ...
I decided to write this example because this has been asked many times at the forums. In my previous article I have shown on how to Upload and Save the Images to Database, In this article I will show on how to upload and save the image to folder and path to database. To get started, let’s create a simple database table for storing the Image information and path to the database. I this example I named the table as “ImageInfo” with the following fields below: Note:I set the Id to auto increment so ...
In my previous article, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes. Now, seems that most of the developers are asking if how to save all the data that was entered from the dynamic textbox in the GridView to the database. So in this example, I’m going to show on how to save them all in the database. To get started then lets create a sample Table in SQL Server. In this example, I named the table as “SampleTable” with the following fields below: Note: I set the ...
With Twitter becoming more and more popular, I have always wanted to explore its developer wiki and find out ways to post to Twitter programmatically. While there are a tons of third party tools such as TweetDeck etc., that allow you to tweet right from your desktop, I was looking for a resource that allows me to update my Twitter status from ASP.NET. I stumbled upon this video http://www.pluralsight.com/... for read/write ...
Incorporating the jQuery Grid With ASP.NET MVC Scenario: You have an ASP.NET MVC application and don't want to custom build smart controls like the ASP.NET GridView, ListView, etc, that support sorting and paging, as well as filtering and searching for data, and all of this using Ajax. Solution: The jQuery Grid plug-in. What tools/plug-ins do I need? jQuery version 1.3 and up jqGrid version 3 and up (this post references version 3.4.4) A strong cup of coffee In the past you had to also add the jQuery ...
I decided to write this example because this has been asked many times at the forums. In this article, I will show on how to sort GridView columns manually using a DataTable. Note that in this example, I used my own database for populating the GridView. See Adding Rows in GridView for more info. Now to get started lets set up the GridView with TemplateField columns. Since we are working with TemplateFields then we need to handle sorting manually by adding a LinkButton control inside the HeaderTemplate ...
Building web-apps using the new MVC-framework for ASP.NET can be challenging if you need to build the boiler-plate code for the SMART controls that come standard with ASP.NET, like the GridView, ListView, etc. However, jQuery's (see jQuery in Action for an excellent resource) plug-in, jqGrid, makes this easy. Although it can be time-consuming to setup the template that specifies the requirements for the grid, it is easy to duplicate once you have it set up. So basically you specify the columns you ...
Seeing as I wrestled with this topic for the better part of a day, I'll post the process here for posterity and for the off chance someone finds it useful. Pardon my lack of proper terminology here. I'd rather get the concept down quickly than look everything up. In your ASPX page, your GridView control needs an OnSorting setting. <asp:GridView ID="SomeName" runat="server" AllowSorting="true" AutoGenerateColumns="false" OnSorting="gvSorting"> Now, in your code behind, you need to have a code ...
I wanted to display Boolean data in a Gridview and didn't like that disabled checkbox look. After searching online, I found some people solved this with Javascript, including the MS AJAX extentions toolkit which has an extender - but I didn't want to have a lot of checkboxes in my html that got replaced on the client's side with javascript that had to loop over them all. I just wanted the images. The quick-and-dirty way to solve this would have been to create a template column for my Gridview with ...
Few days ago, a developer posts a comment in my previous article about “Adding Dynamic Rows in ASP.Net GridView Control with TextBoxes” asking if how to implement the same functionality with DropDownList. In this example, I will going to show on how to generate a Row in GridView with DropDownList when clicking a Button that is residing inside a GridView Footer and retain the Selected Items of the DropDownList on postbacks. Here are the code blocks below: ASPX Source: <html xmlns="http://www.w3.org/19... ...
I decided to write this example because this has been asked many times before at the forums. As you may know, we cannot "directly" hide AutoGenerateColumns in our codes using the code below: GridView1.Columns[index].Vi... = false; Why? This is because auto generated columns are not added in the GridView columns collection.Using the code above will give you "index was out of range error". In this example I will show the different ways on how to hide specific column in GridView with AutoGenerateColumns ...
This post was going to be a rant about how using the ObjectDataSource was impossible to handle exceptions thrown while retrieving or updating data. After some experiments and reading some misleading posts I saw only three possible ways: Use a generic error handler like the Page Error event or the Application Error event in global.asax. Implement handlers for the Updating, Selecting and Deleting events of the GridView bound to the datasource, set the event.Cancel to true and then manually call the ...
I decided to write this simple demo because this issue has been asked many times at the forums. Hidden columns are fields in GridView that you don’t want to expose or show in the page, usually this field is the primary key of the data. Since a primary is a confidential data then you might want to hide it to the users. Most people usually use BoundField columns for displaying the data and just hide the field that contains the primary key. In this example, I will demonstrate two ways on how to access ...
While C# is a computer language, Microsoft Visual C# is a programming environment used to create various types of applications, including console, graphical (GUI), XML, databases, and file-based, etc. This web site provides lessons and other topics on using Microsoft Visual C#, any version (Microsoft Visual C# 2005 Express Edition or Microsoft Visual C# Professional). Windows Controls Button Browse for Folder Check Box Checked List Box Color Dialog Combo Box Context Menu Data Grid View Date Picker ...
This example is a continuation of my previous post about “Adding Rows in GridView”. In this example I will going to demonstrate on how we are going to do Edit, Update and Delete operations in GridView using TemplateField Columns. If you wan’t to implement those operations using BoundField Columns then you can refer to my previous example about “GridView: Insert, Edit, Update and Delete – the ADO.NET way”. Since this example is a continuation, then I would recommend you to start reading this example ...
This example shows on how to add rows of data in the GridView control. In this example, I created a simple database table called “Table1” for storing the data. The Table has the following columns: Id – PK Employees Position Team Note that I added some dummy data in table that I have created so that we can display something in the GridView when the page is loaded for the first time. To get started, let’s grab a GridView Control from the Visual Studio ToolBox and place it in the webform. Then set up ...
This is a similar technique to the one outlined in this post. The idea is simple, you have a data value that you want to pass to a Javascript function through a button click on a GridView row. The example below shows how to pass a variable, in this case OtherID, to a Javascript function that opens a new modal window which holds a different aspx page. function ShowOther(OtherID) { window.showModalDialog('Oth... + OtherID, 'dialogHeight:600px;dialogW... } In the GridView ...
Introduction: I decided to write this article because this has been asked so many times before at the forums(http://forums.asp.net) . Basically, this example shows on how to generate a Row in GridView with TextBoxes when clicking a Button that is residing inside the GridView footer. To get started, let’s grab a GridView control from the Visual Studio Toolbox and put it in the WebForm. The mark up would look something like this: <asp:gridview ID="Gridview1" runat="server" ShowFooter="true" AutoGenerateColumns="false"... ...
There are certain scenarios that we need to combine an AutoGenerated Columns with TemplateField Columns or even BoundField Columns in the GridView. As we all know, by default the GridView will automatically display all the AutoGenerated Columns to the rightmost column of the GridView. Consider this example below: Assuming that we have this GridView markup below: <asp:GridView ID="GridView1" runat="server"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Button ID="Button1" ...
I decided to post this because this has been asked many times before at the forums. So for those who doesn't know how to generate a control event that are residing within the TempleFields of GridView then you can follow these few steps below: * Switch to Design View in Visual Studio Designer * Right Click on the GridView * Select Edit Template and then Select the Column where the Control that you wan't to generate the event resides (e.g Button, TextBox, etc..) * The GridView will then changed to ...
Gizmox released today a new version of the Visual WebGui Platform for Rich .NET AJAX applications. Visual WebGui 6.3.7 is a further stabilization to the 6.3 pre-release version which adds support for wrapping of AJAX based controls into the Visual WebGui framework as well as support for additional languages. The platform is available in free open source and free trial (commercial Professional Studio) versions. All downloads are available for free here! This is the Change log for 6.3.7: Breaking Changes ...
I decided to write this post because I always encounter this kind of issue so many times before at the forums. The main question is that they want to automatically calculate the totals when a user enter an amount from the TextBox control that is residing in the GridView template. So this example shows the basic way on how to achieve this with the server side manipulations. Note that this demo requires that you know the basics of ADO.NET and for binding a GridView control with data from database. ...
There are two ways to disable the CSS Friendly Adapters in ASP.NET: 1. In the Browser file Adapters for a specific control type can be disabled by just commenting out (deleting) the type of control adapter in the browser file. The effect is global and will affect all the controls of this type. For examle, to disable the adapter for GridView type: <!--<adapter controlType="System.Web.UI.... adapterType="CSSFriendly.Gr... />--> 2. At the control level Adapter ...
Background : In my last post about SQL Server 2008 new feature File Stream (Saving and Retrieving File Using FileStream SQL Server 2008), we did an example of saving an image to the file stream and then retrieve it back and make it available for download. The result of that example looks like as below. But, one has to press the button to download the image file. One of my blog reader raise a point that he wants to display the same image instead of Get File button which is going to download. Introduction ...
We had a scenario where there's a necessity to display the column headers vertically. Usually the headers will be horizontals by default. Below picture shows the default headers. The needed ouput was displayed below. The Grid control that is used for this display is GridView. So I did a little bit of search and found some good solutions in the web. It's all achievable with styles. Step 1: Create the following styles in the Master page file or the Style class file or in the page where required. <style ...
ASP.Net Listview is a Template Driven Grid control from Microsoft. It combines the features of DataGrid, GridView and Repeater. There is lot of web resources available about ListView. I had a scenario where the grid control has to act like an Excel control. Excel allows us to enter data in each of the cell. Then a submit button can be used to perform the Update or Delete operation on the Bulk. Referral Links: http://weblogs.asp.net/scot... ...
So, it takes too long for me to write this post. even though I completed the coding stuff a week back but it is really hard to manage time these days. In this post, I will explain and demonstrate you how to create custom paging in Grid view control. Paging which works like the Google Paging. Let me elaborate more, say for example you have a record set of 500 items and you want to display 10 items per page. Now what happen to the pages numbers. Either you use the default with “..” sign after 10th ...
Here is one way to have data load only when a TabPanel is clicked. In my example I have an aspx page with a TabContainer, two TabPanels both with their own ObjectDataSources that fill GridViews. The first tab’s ObjectDataSource and GridView will run on the page load and that is fine since it would be the first thing a user sees. The overall idea is to have the ObjectDataSource for the second tab to not run on the page load and then have the GridView on the second tab databind only when the tab is ...
This post goes along with this previous post on calendar extender display issues. However the formatting fix I used was much less involved than before. Again I had a GridView with some text boxes for dates that I added the CalendarExtender to. And just like before the GridView had some CSS specific to it’s td which involved padding and text alignment. I added all the CalendarExtender styles to my css file and the extender worked fine but did not look quite right. The current date listing was quite ...
This example shows how to “PIVOT” the original data that is displayed in the GridView. To start then lets grab two GridViews from the Visual Studio Toolbox and place it to your webform. The ASPX source would look something like this: ORIGINAL Table: <asp:GridView ID="GridView1" runat="server"> </asp:GridView><br /><br /> PIVOTED Table: <asp:GridView ID="GridView2" runat="server" ShowHeader="false"> </asp:GridView> Now, lets create the Generic method for Pivoting ...
This example shows how to filter data in GridView based from two given dates. For example you have two Calendar Control which is allows you to select the Start Date and End Dates accordingly. These selected dates will then be displayed in TextBoxes and later on you wish to Grab the data from the database based from the dates (StartDate and EndDate) that is displayed in the TextBox and bind the result to a GridView control. Here are the code blocks below: private string GetConnectionString(){ //call ...
Wczoraj (tj. 06.05.2009) pojawil sie nowy preview - Preview 4 bibliotek CRUD dla ASP.NET, a wiec Dynamic Data. W moim moralnym obowiazku jako fana DD znajduje sie w zwiazku z tym opisanie nowego release’u. Ten post zapoczatkuje serie na temat Dynamic Data, w wersji aktualnej, a pózniej Futures, tak aby przekonac programistów ASP.NET, ze Dynamic Data nie gryzie. Do kogo jest skierowany ten post? Glównie do ludzi, którym Dynamic Data sie przyda. Wiec raczej nie do tych, którzy pracuja nad projektami ...
Gridview is one of the good controls which enables us to produce Excel like output in the webforms.You can learn more about grid view in the following link GridView Documentation We had a scenario where we are supposed to give freeze pane like feature for Gridview. We had a lengthy Grid with some 20 or 30 columns . We had paging for about 20 records per page. So following were the requirements. 1. Grid must have a Fixed header. 2. it should be scrollable horizontally. 3. it should be scrollable vertically. ...
One of the member at the http://forums.asp.net ask if how to wrap the data in the GridView Control. See this thread (http://forums.asp.net/t/14... I decided to post the solution that I was provided in that thread as a reference for all who needs a solution for the same issue. Here’s the code block below: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[0].Attributes.A... "word-break:break-all;word-... ...
I wrote this demo because I observed that lots of people in the forum (forums.asp.net) always ask questions on how to display Image that was stored in the database to GridView control. Before reading this example, be sure that you have already know how to upload image to the database. If you are not familiar with it then I would suggest you to read my previous example about “Uploading and Storing Images to Database in ASP.NET”. In this demo, we are going to use a Handler.ashx file for fetching the ...
This example is a continuation of my previous example about “Uploading and Storing Images to Database in ASP.NET”. In this demo, I’m going to show how to display image (binary format) from database to ASP Image control and display its corresponding image information based on user selection. In this demo, we are going to use a Handler.ashx file for fetching the binary data from the database and then stream it. What is a Handler? A handler is responsible for fulfilling requests from a browser. Requests ...
This is another installment of how to use the ASP.NET ListView and Repeater to generate repeating groups of controls in ASP.NET pages in scenarios which often lead developers to add unnecessary complexity to their pages by resorting to dynamically generated controls. Part 2 demonstrated using the ListView control to maintain the values in a repeating group of textboxes, using a collection of strings as a data source,and allowing the user to add rows as required. This works well for simple scenarios, ...
I will explain how to develop a simple application in ASP.NET using a three-tier architecture. The presentation tier The business tier The data tier Concepts: The presentation tier contains the UI (User Interface) elements of the site, and includes all the logic that manages the interaction between the visitor and the client’s business. (ASP.NET Web Forms,Web User Controls,ASP.NET Master Pages) The business tier receives requests from the presentation tier and returns a result to the presentation ...
About a year ago, I started to evaluate ASP.Net MVC, but decided to put it aside because it was still in heavy-duty development. With the official release a couple of weeks ago, I decided to check it out once again. MVC has a lot of things to offer, but there are a few critical things that we couldn’t overlook. We have a few web applications that all have quite a lot invested in server controls (both third-party and developed in-house). In ASP.Net WebForms, for something as simple as a GridView with ...