Posts

Showing posts with the label Web controls

How to highlight rows in a DataGrid using a CheckBox

This is for highlighting rows in a DataGrid using a CheckBox private void dgvItemsDetails_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dgvItemsDetails.Columns[selected.Name].Index == e.ColumnIndex) { dgvItemsDetails.MultiSelect = true; if (Convert.ToBoolean(dgvItemsDetails[selected.Name, e.RowIndex].FormattedValue) == true) { dgvItemsDetails[selected.Name, e.RowIndex].Value = false; } else { dgvItemsDetails[selected.Name, e.RowIndex].Value = true; } } int i = 0; foreach (DataGridViewRow dgvrow in dgvItemsDetails.Rows) { if (Convert.ToBoolean(dgvrow.Cells[0].Value.ToString()) == true) ...

Export Data Grid in Excel Word And Text File

In this article I am going to show how can you export a data grid data to a excel, word and text file. This is the aspx code. See full detail: http://www.c-sharpcorner.com/UploadFile/rahul4_saxena/ExportDataGridinExcelWordAndTextFile07032009024235AM/ExportDataGridinExcelWordAndTextFile.aspx

GridView Formatting

This article shows how to format a GridView. What is GridView? The GridView is an extremely flexible grid control for showing data in a basic grid consisting of rows and columns. It has selection, paging and editing feature, and it is extensible through templates. The great advantage of Gridview over Datagrid is its support for code free scenarios. In GridView you can do many things without writing any code like paging and selection. Formatting Fields: To format the grid view you have to ensure that dates, currency and other number values are in good format. Grid View has property "DataFormatString" to apply formatting. You can change colors, fonts, borders and alignment of grid. Each BoundField column provides a DataFormatString property that you can use to configure the numbers and dates using a format string. Format strings are generally made up of a placeholder and format indicator, which are wrapped inside curly brackets, like this: {0:C} Here 0 shows the value that will...

Databinding with Repeater control in asp.net with C#

Data presentation is an important goals of any application development process. ASP.NET 2.0 provides many server controls which render data in different rich formats and styles. for example Datalist, Gridview, repeater control etc. Here I am going to discuss about repeater control in detail. Repeater control is a template based container control. you define layout for the Repeater control by creating different templates based on your needs. The Repeater control may be bound to a database table, an XML file, or another list of items. Here we will show how to bind data to a Repeater control. Repeater Control Templates Repeater controls provides different kinds of templates which helps in determining the layout of control's content. Templates generate markup which determine final layout of content. These are as follows: HeaderTemplate ItemTemplate AlternatingItemTemplate FooterTemplate SeparatorTemplate ItemTemplate: ItemTemplate defines how the each item is rendered from data source...

Expanding / Collapsing GridView Columns with Smooth Dynamic Effect

Image
Introduction Last year I had posted an article: Expanding / Collapsing GridView Rows . In that article, I had described implementation details of Expanding / Collapsing rows of a GridView using JavaScript with smooth dynamic effect. Now through this article, I'm going to demonstrate how to expand and collapse columns of a GridView using JavaScript with smooth dynamic effect. CSS Code I've used the following CSS classes for this demo. Header and Footer CSS classes have been used for GridView ’s header and footer rows respectively and Row and AlternateRow CSS classes for GridView ’s normal and alternate rows respectively. Grid CSS class has been used for GridView ’s background. See full detail: http://www.codeproject.com/KB/webforms/GVColumnsExpandCollapse.aspx

Creating an ASP.NET GridView Custom Field of type DropDownList

Image
Introduction Sometimes, you need to use a DropDownList in a GridView in a way to see the text of fields and save values in to your database. Here, we have extended the “ BoundField ” class and added features to create a column type of “ DropDownList ”. For example, in this picture, you can see two tables, Customer and Category . Suppose you need to edit the content of the Customer table with a GridView and select “Customer Category” through a “ DropDownList ”. You want to see the CategoryName in the grid but save CategoryID in to the database, like in this picture: Background You have two solutions: The first solution is to create a Template column of type DropDownList . The second solution is to create a new column type with the “ DropDownList ” editor and introduce an “Entity Name” for it. Here, we have extended the “ BoundField ” class and added features to create a column type of “ DropDownList ”. Using the code Now, you can use this column type easil...

DayPilot Scheduler Control for ASP.NET

Image
Live Demos Monthly scheduler Weekly scheduler Daily scheduler Free/busy scheduler Timeline Features Main features: Simple and clean look Multiple resources on the Y axis Customizable time scale on the X axis (one cell = 1 minute, 1 hour, 1 day, 1 week ...) Highlights business hours (customizable color) Automatically handles concurrent events Customizable event box (text, size, background color, duration bar...) Customizable fonts and colors Database connectivity: DataSource and DataSourceID properties supported SqlDataSource XmlDataSource DataTable DataSet ArrayList and other sources... Event handling: Free time slot click event (automatic PostBack or manual JavaScript handling) Calendar event click event (automatic PostBack or manual JavaScript handling) Licensing: Open-source (Apache Software License 2.0) Compatibility: Internet Explorer 6 Internet Explorer 7 Firefox 2 Firefox 3 Opera 9 Safari 2 Safari 3 Google Chrome 1 Se...

GridView:Sorting & Paging Using Generics And Nullable Datatype Function Of C# GetValueOrDefault()

Image
Introduction The idea behind writing this article is to overcome the problem related to sorting of collection having null values in it. Recently I was working with GridView control and I was using generic collection list as a data source to it. While resolving this problem alone I developed a good piece of functionality which I do feel will help most of you in your development activity. Features Available The feature incorporated in the GridView are as follows: Used C#'s Generics Used Nullable Datatype Used Generics Collection IList To Bind GridView. Sorting Of Generics Collection IList Using IComparer Interface . Applied Nullable Datatype function GetValueOrDefault for Sort Operation On Nullable Datafield. Fully Tested Concurrent Sorting And Paging Operation In GridView. Problem Statement I had nullable value field data type in my database table. So I used nullable datatype of C# in my asp.net code. Doing so I encountered sorting failure problem with IComparer....

Web Paging Navigation Control

Introduction this web paging control for navigation in data list . how to use this control 1-Set Control setting in page load 2-to get page index from this control use PagingControl1_PageIndexClick(object sender, EventArgs e) event Sample for how to use this control see full detail: http://www.c-sharpcorner.com/UploadFile/Nesreeen/WebPagingControl05182009155353PM/WebPagingControl.aspx

Populate data in dropdown in asp.net

Populate data in dropdown in asp.net: C# Code: using System.Data; using System.Data.SqlClient; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlConnection cn = new SqlConnection("Server=localhost;database=test;uid=sa;pwd="); SqlDataAdapter da = new SqlDataAdapter("Select ID,productName from Products", cn); DataSet ds = new DataSet(); try { da.Fill(ds); DropDownList1.DataSource = ds.Tables[0]; DropDownList1.DataTextField = "productName"; DropDownList1.DataValueField = "ID"; DropDownList1.DataBind(); } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); da.Dispose(); ds.Dispose(); } } }

Display data in GridView in asp.net

Display data in GridView in asp.net: using System.Data; using System.Data.SqlClient; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlConnection cn = new SqlConnection("Server=localhost;database=test;uid=sa;pwd="); SqlDataAdapter da = new SqlDataAdapter("Select * from Products", cn); DataSet ds = new DataSet(); try { da.Fill(ds); GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); da.Dispose(); ds.Dispose(); } } }