Tag | GridView Posts

Introduction: This question has been asked many times at the forums (http://forums.asp.net) and definitely there are already bunch of different solutions provided. Most of the examples from the web are using DataSource controls (e.g SqlDataSource, ObjectDataSource, etc..) to implement cascading DropDownList in GridView and I can’t seem to find a formal example that demonstrate how to implement it without using DataSource controls. Note: Before you proceed, make sure that you already know the basics ...
This question was asked from the forums.asp.net and thought I’d blog about it for future reference. The question is “how do we set ReadOnly for autogenerated columns in gridview when it’s on edit mode?”. Well as you may know autogenerated columns are created dynamically on the fly and so we need to manually access each columns in the code before we can set their properties. To make it more clear we’ll create a simple demonstration. Consider that we have this HTML mark-up below: <asp:GridView ID="GridView1" ...
A couple of months ago I’ve written a simple demo about “Highlighting GridView Row on MouseOver”. I’ve noticed many members in the forums (http://forums.asp.net) are asking how to highlight row in GridView and retain the selected row across postbacks. So I’ve decided to write this post to demonstrate how to implement it as reference to others who might need it. In this demo I going to use a combination of plain JavaScript and jQuery to do the client-side manipulation. I presumed that you already ...
The ComponentOne team presents the most complete collection of extensions for Microsoft Visual Studio LightSwitch. This collection of ready-to-use extensions snaps right into your applications and extends their functionality. You can choose from the following extensions below:" OLAP – instant pivoting data views FlexGrid – grid view with conditional formatting, printing and filtering Chart – the easiest way to get a chart in LightSwitch PDFViewer – open PDFs such as SSRS reports without an external ...
HiI was doing some test with code first approach in EF. Then while populating the Gridview i was getting error like thisData binding directly to a store query (DbSet, DbQuery, DbSqlQuery) is not supported. Instead populate a DbSet with data, for example by calling Load on the DbSet, and then bind to local data. For WPF bind to DbSet.Local. For WinForms bind to DbSet.Local.ToBindingList()... solving this error we have to write the code like this private void FillGrid() { using (var Context = new ...
Recently I was working with data from a generic List<T> and one of my objectives is to get the distinct values that is found in the List. Consider that we have this simple class that holds the following properties: public class Product { public string Make { get; set; } public string Model { get; set; } } Now in the page code behind we will create a list of product by doing the following: private List<Product> GetProducts() { List<Product> products = new List<Product>(); Product ...
This post is pretty specific to an issue I had but still has some ideas that could be applied in other scenarios. The problem I had was updating a few buttons so their Text values could be set in the code behind which had a method to grab the proper value from an external source. This was so that if the application needed to be installed by a customer using a language other than English or needed a different notation for the button's Text they could simply update the database. Most of the time this ...
If you tried to build applications for Windows 8 with XAML/C#, you may have noticed an annoying issue: If you have a list controls (for example a GridView) and you bind the ItemsSource property to a property of type ObservableCollection on your ViewModel, the GridView is not updated when the collection’s content changes. The CollectionChanged event is raised properly, but it is not honored by the binding system. Read the rest of this entry » ...
I’ve been seeing many members in the forums asking how to display a large copy of the image on mouseover. Some of them are displaying the image in a Repeater, GridView or DataList control. I didn’t find any direct solution that shows the scenario they wanted so I thought of writing this post to demonstrate how to go about it. I know there are lot of ways of doing/implementing a solution for this scenario and this is just one them. In this example I’m going to use the DataList control for displaying ...
Here is one way to access a control in a GridView right after a user clicks a button to change from view to edit mode. This example shows a TextBox that gets populated with today's date. The GridView is setup like this:<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="TestID" DataSourceID="SqlDataSource1" onrowdatabound="GridView2_R... > <Columns> <asp:TemplateField> <ItemTemplate> <asp:Button ID="btnEdit" runat="server" Text="Edit" ...
One of the main attraction points to this offering in my review is how does it fit into the work I do and solutions I recommend. Right off, the fact it has capabilities described as Silverlight focus/MVVM , makes it something that intrigued me. I tested the different capabilities it has from using it in WinForms and WPF as well, and Silverlight. One of the main points is the C1DataSource, it shows a level of simplicity through the property dialogs that allows you to move right along with, for example, ...
At http://weblogs.asp.net/scot... Scott Guthrie talks about data binding is ASP.NET 4.5.There is a key statement "Because our GetProducts() method is returning an IQueryable<Product>, users can easily page and sort through the data within our GridView. Only the 10 rows that are visible on any given page are returned from the database."Consider paging through a large dataset, this is going to give ...
Here is a technique to bind a List (of objects) to a DataGridView so that the public Properties appear as columns. In this example, the columns are binded to the individual public property of the object. The column Random Number is binded to the public property RandomNumber while the column Square Root to the public property SqRt. Create a class that contains the public properties that appear as columns in the dataGridView 1: using System; 2: using System.Collections.Generic; 3: using System.Linq; ...
In SQL Server 2008 you can use table valued parameters which can be pretty useful. In the example I use a very simple one to overcome SQL Server’s lack of having a parameter as an array. The example goes through creating the new type, using it in a stored procedure and calling it from an application (VB.Net in this example). You start off with creating the new type. Under Programmability/Types/User-... Table Types create a new table. Here I created a table with a single column to hold an integer. ...
Programming for Metro Metro is the future http://zd.net/rnT9VZ .NET is for old apps. WinRT replaces WPF & WCF. XAML is big. There were no Silverlight sessions. HTML 5 and Javascript ( Blend for HTML) are back in fashion – I wont dwell on this because web apps are (inconsistently) simplistic in concept and over-complex in development. Yes, all those XAML skills are portable, Silverlight (RIP) apps can run as Metro apps with a bit of fidgeting with namespaces – you just need to know what controls ...
A developer is asking how to pass data from a UserControl control to the main page. Basically, the scenario is that he has a user control which contains a GridView and wrap arround within asp Ajax UpdatePanel control. The UserControl will then be used at the page that is hosted within a master page. The page contains some TextBox in which it will be populated once the user selects a row from the GridView also on that page the Modalpop is defined. To achieve that, here's one solution I've provided ...
A new release of Microsoft All-In-One Code Framework is available on July 13th. We expect that its 17 new code samples would reduce developers’ efforts in solving the following typical programming tasks. Download address: http://1code.codeplex.com/r... Alternatively, you can download the code samples using Sample Browser or Sample Browser Visual Studio extension. They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized ...
Sometimes you need to access a control within a GridView, but it isn’t quite as straight forward as just using FindControl to grab the control like you can in a FormView. Since the GridView builds multiple rows the key is to specify the row. In this example there is a GridView with a control for a player’s errors. If the errors is greater than 9 the GridView should display the control (lblErrors) in red so it stands out. Here is the GridView: <asp:GridView ID="gvFielding" runat="server" DataSourceID="sqlFielding" ...
Luego de varios días de intenso trabajo, hoy he tomado un pequeño espacio de tiempo para dedicar un post al trabajo con datos en forma de tablas en asp.net Todos los que hemos trabajado desde hace bastante con asp.net, hemos aprendido a querer al GridView, un excelente control que nos permite mostrar los datos directamente desde una base de datos y trabajar con ellos, llamase trabajar a las operaciones de: editar, buscar, agregar y eliminar. Por supuesto que existen muchas otras opciones que no son ...
Últimamente he visto muchas consultas sobre como colorear las celdas o filas de un gridview basados en un determinado valor o condición. Así que el objetivo de este post es mostrar como realizar este procedimiento, pero además añadiremos un elemento mas, que es como mostrar una imagen dependiendo de una condición. Empezaremos trabajando en como cambiar el color de una fila del Gridview: Supongamos que tenemos un Gridview que tiene un campo de tipo Literal en un TemplateField que muestra un total ...
I was looking for a way to delete many objects (selected in a GridView) in one query instead of iterating each ActiveRecord and executing the .Destroy(). I tried the following but it didn’t work myActiveRecordCollection().... I used this instead Dim items As New ArrayList() For Each Item Selected in the GridView items.Add(the id of the record I want to delete) Next Dim query As New SubSonic.Query(Table.Schema) query.QueryType = SubSonic.QueryType.Delete query.IN("ColumnName", list) query.Execute() ...
Typically we will attach the mouseover and mouseout client-side events on the gridview rows to highlight rows on mouseover, but there are cases that we don't want to make the row highlighted when we are on edit mode. To do this we can check the GridView EditIndex to determine if the row is on edit mode and then do the validation there. Here's a sample code block below of what I am talking about: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) ...
One of the greatest benefits I’ve found in simple web output in ASP.NET is the GridView. I regularly use it to display data from objects or databases where the output can simply be shown in a grid form (similar to instances where I would deliver a read-only spreadsheet). I attach the GridView to the <asp:PlaceHolder /> inside of a <form /> on the aspx page: A simple, bulk method of getting the data into the GridView is with the GridView.DataSource property. A GridView.DataSource must ...
Ajax enabled data centric applications are getting popular day by day in web development space. While these type of web applications provide rich user experience, building a robust and powerful application quickly is a great challenge for developers. Fortunately Microsoft has started providing great frameworks, plug-ins and APIs to facilitate this process. Last week Microsoft announced a new version of java-script API “datajs”, which is intended to help web developers to build data centric AJAX applications ...
private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { int row = e.RowIndex; int col = e.ColumnIndex; if (dgv.CurrentCell is System.Windows.Forms.DataGr... { DataGridViewCell cell = dgv.CurrentCell; DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)d... //-------------------------... // //-------------------------... bool newBool = (bool) checkCell.EditingCellFormat... ...
Since .NET Framework 3.5, to show the Header row in empty GridView, you need to do some trick like: List<string> rows = new List<string>( new string[] { "line1", "line2", "line3" }); rows.Clear(); if (rows.Count > 0) { gv.DataSource = rows; gv.DataBind(); } else { rows.Add(""); gv.DataSource = rows; gv.DataBind(); gv.Rows[0].Visible = false; } Obvious, the “else” condition will be always executed, but this is only for exemplify. On .NET Framework 4.0, was introduced a new property, ...
ASP.NET Export n GridViews to Excel Thanks to awesome article by Matt Berseth http://mattberseth.com/blog... http://forums.asp.net/t/152... //Web Page Call to ExcelExport Class protected void lnkExport_Click(object sender, EventArgs e) { //creating the array of GridViews and calling the Export function GridView[] gvList = new GridView[] { gvPlateList, gvPlateDetails }; ExcelExport.Export("Deliver... gvList); } //ExcelExport Class using System; ...
UPDATE: Scott Hanselman has a NuGet package to automate many of these steps and you should check it out, http://www.hanselman.com/bl... Today, at Tech Ed India 2011, I delivered this session – Web Forms vs. MVC choosing the right one for web development. Although its a tricky topic, it was worth clarifying some of the patterns to decide between Web Forms and MVC. One of the demo scenarios I took ...
If you didn’t know, you probably will soon, the SPGridView is not available in Sandboxed solutions. To be honest there doesn’t seem to be a great deal of information out there about the whys and what nots, basically its not part of the Sandbox SharePoint API. Of course the error message from SharePoint is about as useful as punch in the face… An unexpected error has been encountered in this Web Part. Error: A Web Part or Web Form Control on this Page cannot be displayed or imported. You don't have ...
A developer is asking how to select one radio button at a time if the radio button is inside the GridView. As you may know setting the group name attribute of radio button will not work if the radio button is located within a Data Representation control like GridView. This because the radio button inside the gridview bahaves differentely. Since a gridview is rendered as table element , at run time it will assign different "name" to each radio button. Hence you are able to select multiple rows. In ...
ASP.NET Conditionally Change ButtonField text at runTime <asp:ButtonField CommandName="Edit" HeaderText="" Text="Edit" ButtonType="Link" /> protected void gvRequests_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //-------------------------... // If status = "Saved", change buttonField.LinkButton.Text to "Copy" //-------------------------... if (e.Row.Cells[(int)gCol.Stat... == "Saved") ...
Microsoft provide an article of the same name (previously published as Q319401) and it shows a nice class 'ListViewColumnSorter ' for sorting a standard ListView when the user clicks the column header. This is very useful for String values, however for Numeric or DateTime data it gives odd results. E.g. 100 would come before 99 in an ascending sort as the string compare sees 1 < 9. So my challenge was to allow other types to be sorted. This turned out to be fairly simple as I just needed to create ...

At http://www.4guysfromrolla.com/articles/120810-1.aspx there is very useful article on using jQuery to check all / uncheck all checkboxes in a GridView.  - Enjoy!

I wrote a series of blog posts awhile back before that demonstrates the following: Uploading and Storing Images to Database in ASP.NET Displaying Image to Image Control based on User Selection in ASP.NET FAQ: Displaying Image from Database to GridView Control Uploading and Storing Image Path to Database and Image to Folder - Part 1 Uploading and Storing Image Path to Database and Image to Folder - Part 2 (Displaying of Images) Validate Image extensions upon Upload In this post I'm going to demonstrate ...
I read a blog post a few months back about client binding your Asp.Net GridView. It was Called Bind Gridview using Jquery. I took it to heart and now I'm using it, except it doesn't handle client sorting (paging is another story). Granted this has some room for improvement and my js isn't the best… Base Page method with the grid view: protected void SetHeaderAttribs(GridView grid) { for (int i = 0; i < grid.Columns.Count; i++) { TableCell cell = grid.HeaderRow.Cells[i]; DataControlField field ...
Bubble Web User Control Event to Parent Web Page ///////////////////////////... //User Control ///////////////////////////... public partial class UserControls_ListRequests : System.Web.UI.UserControl { // Delegate declaration public delegate void GridSelectHandler(int requestId); // Event declaration public event GridSelectHandler GridSelectEvent; protected void gvRequests_SelectedIndexCha... sender, EventArgs e) { ...
I wrote a blog post a while back before here that demonstrate how to highlight a GridView row on mouseover and as you can see its very easy to highlight rows in GridView. One of my colleague uses the same technique for implemeting gridview row highlighting but the problem is that if a Column has background color on it that cell will not be highlighted anymore. To make it more clear then let's build up a sample application. ASPX: 1: <asp:GridView runat="server" id="GridView1" onrowcreated="GridView1_Row... ...
A user in the forums (http://forums.asp.net) is asking how to insert sub rows in GridView and also add delete functionality for the inserted sub rows. In this post I'm going to demonstrate how to this in ASP.NET WebForms. The basic idea to achieve this is we just need to insert row data in the DataSource that is being used in GridView since the GridView rows will be generated based on the DataSource data. To make it more clear then let's build up a sample application. To start fire up Visual Studio ...
El día de hoy veremos como trabajar con los controles ListView e Imagelist de WindowsForms para poder leer y mostrar una serie de imágenes. Antes de ello debo decir que pueden existir otras formas de mostrar imagenes que solo requieren un control por ejemplo con un Gridview pero eso será en otro post, ahora nos centraremos en la forma de realizarlo con los controles antes mencionados. Lo primero que haremos será crear un nuevo proyecto de windows forms, en mi caso utilizando C#, luego agregaremos ...
The code samples in Microsoft All-In-One Code Framework are updated on 2010-12-13. Download address: http://1code.codeplex.com/r... Updated code sample index categorized by technologies: http://1code.codeplex.com/w... (it also allows you to download individual code samples instead of the entire All-In-One Code Framework sample package.) If it’s the first time that you hear about Microsoft All-In-One Code Framework, ...
Es común ver en los foros, preguntas sobre como llenar un datatable para luego, ponerlo como fuente de un GridView. En nuestro próximo ejemplo, mostraremos lo sencillo que puede ser y la poca cantidad de código que es requerida: using (SqlConnection c = new SqlConnection("conectionstr... { c.Open(); // Crear un nuevo DataAdapter using (SqlDataAdapter a = new SqlDataAdapter("SELECT * FROM table", c)) { // Usar un DataAdapter para llenar el DataTable DataTable t = new DataTable(); a.Fill(t); gridView1.DataSource ...
Recently I wrote a series of blog posts that demonstrates how to do calculation in GridView using JavaScripts. You can check the series of posts below: FAQ: GridView Calculation with JavaScript FAQ: GridView Calculation with JavaScript - Formatting and Validation FAQ: GridView Calculation with JavaScript - Displaying Quantity Total Recently a user in the forums is asking how to calculate the total quantity, sub-totals and total amout in GridView when a user enters the price and quantity in the TextBox ...
Previously we've talked about how calculate the sub-totals and grand total in GridView here, how to format the numbers into a currency format and how to validate the quantity to just accept whole numbers using JavaScript here. One of the users in the forum (http://forums.asp.net) is asking if how to modify the script to display the quantity total in the footer. In this post I'm going to show you how to it. Basically we just need to modify the javascript CalculateTotals function and add the codes ...
In my previous post here we've talked about how to calculate the sub-totals and grand total in GridView using JavaScript. In this post I'm going take more step further and will demonstrate how are we going to format the totals into a currency and how to validate the input that would only allow you to enter a whole number in the quantity TextBox. Here are the code blocks below: ASPX Source: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml... ...
In my previous post I wrote a simple demo on how to Calculate Totals in GridView and Display it in the Footer. Basically what it does is it calculates the total amount by typing into the TextBox and display the grand total in the footer of the GridView and basically it was a server side implemenation. Many users in the forums are asking how to do the same thing without postbacks and how to calculate both amount and total amount together. In this post I will demonstrate how to do this using JavaScript. ...
Few months ago I wrote a series of blog posts about creating a dynamic rows in GridView and Table. In this example I'm going to demonstrate how to build a simple form that allows you to create a dynamic row using the standard ASP Repeater control. To get started, let’s grab a Repeater control from the Visual Studio Toolbox and place it in the WebForm. The mark up should look something like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml... ...
All-In-One Windows Forms Code Samples Introduction Download Windows Forms code samples Request Windows Forms code samples Introduction The All-In-One Windows Forms code samples demonstrate the typical programming topics about Windows Forms. These topics are either frequently asked in MSDN forums and Microsoft Support, or are requested by many developers via our code sample request function. We want to alleviate the frustration felt by developers when they are developing Windows Forms projects. Visual ...
All-In-One ASP.NET Code Samples Introduction Download ASP.NET code samples Request ASP.NET code samples Introduction The All-In-One ASP.NET code samples demonstrate the typical programming topics about ASP.NET. These topics are either frequently asked in MSDN forums and Microsoft Support, or are requested by many developers via our code sample request function. We want to alleviate the frustration felt by developers when they are developing ASP.NET projects. Visual Studio 2008 ASP.NET Code Samples ...
Private Sub dgCompounds_CellPainting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGr... Handles dgCompounds.CellPainting Try '--------------------------... 'if POS = <blank> , hide 'Punch' checkbox in cell '--------------------------... If e.RowIndex > -1 And e.ColumnIndex > -1 Then If Me.dgCompounds.Columns(e.Co... ...
A few time ago i've write an article explaining how to use iTextSharp. Check it here: http://geekswithblogs.net/g... In this article, i'll show how to use headers. You just should follow this article if you're using iTextSharp 5.x or above. Other versions uses the object HeaderFooter. The last releases, instead of using an object to create the header, uses events. There's a list of existing events in iTextSharp: ...