Skip to main content

Posts

Showing posts from October, 2013

How to Add Commands with Binding in DataGridView: Windows Forms

After binding records with DataGridView, there may be some options to edit or to remove those records. To do these simple task we can provide either a button, which gets the selected record and perform operation, or we can provide the button with each particular record.

We will discuss here how to add a button with particular record with the following simple steps. Drag-n-drop a datagridview on the form and a task pop-up menu will automatically open, click on Add Columns link button to add a new column. It will show following Add Column window.


By default Unbound column radio button have been checked, if not check it and use the following values in respective fields:
Type: DataGridViewButtonColumnHeader Text: Command (Changeable) Sure the Visible check box is checked and click on Add button to add this column. Now you have successfully added a command button with empty text as shown in below image:


To write text on the button generate Cell_Formatting event of dataGridview and set the …

How to Bind ComboBox with List of Items: C#

A list of items is used to store some temporary records, used in the program and do some operations like sorting, grouping and etc. In the previous post we have created a list and bind that list to the datagridview, using its DataSource property.

A combo box also have DataSource property to bind some data as I have discussed in my earlier article i.e. How to bind combobox with database. Combo Box is used to display a single field at a time and a list can contains multiple fields. I will use the same student class as in my earlier articles.
To show a single field, combo box have a property DisplayMember that will specify the field to display. In the following C# code the student list will bind with the combo box and name field will be shown.

List<Student> stuList = new List<Student>();
cmbBox.DataSource = stuList;
cmbBox.DisplayMember = "Name";
Before running this code, you have to sure that your list have some records to show. It will not throw an exception, bu…

GridView Paging in ASP.NET

Introduction There are many things to remember that how a GridView support paging at runtime. Also DOTNET provides many styles is to related paging such as numbering , first and last order etc. Always first think in mind that SqlDataReader does not support paging so do not bind your GridView control with DataReader.
Here we are describe easy steps to bind GridView with paging.Step-1: Drop GridView Control on Designing window and add some attributes in GridView Tag.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="false"             AllowPaging ="true" PageSize ="2"             onpageindexchanging="GridView1_PageIndexChanging1">
Step-2:Bind GridView using ADO.NET Step-3:  Handle onpageindexchanging event in code file.
protected void GridView1_PageIndexChanging1(object sender, GridViewPageEventArgs e)     {         GridView1.PageIndex = e.NewPageIndex;         loadgrid();
    } Step-4 : Run your application
Comple…

ASP.NET Exception : The data source does not support server-side paging

SqlDataReader class does not support paging in ASP.NET.  In above snapshot you can see that your GridView is bind with DataReader instance so if you want to remove this error , replace your DataReader with DataSet or DataTable.

Here are given some easy steps to bind your GridView with Dataset.

 Use DataSet for enable pagingDataSet ds = newDataSet(); SqlDataAdapter da = newSqlDataAdapter(cmd);         da.Fill(ds);         GridView1.DataSource = ds;         GridView1.DataBind();
Paging Example in ASP.NET

Difference Between SGML, HTML, and XML

XML , markup languages such as standard Generalized Markup Language(SGML) and Hypertext Markup Language(HTML) are also available.

SGML was released in 1980. It allows documents to describe their grammar by specifying the tag set used in the document and the structural relationship that these tags represent. This makes it possible to define individual formats for documents, handle large and complex documents, and manage large information repositories. However, SGML is complex and difficult for developers to master.

HTML was created by Tim Berners-Lee in 1989 as a simple and effective way of generating clear and readable documents. HTML enables you to create documents and Web pages that can be read by all web browsers . It uses a set of tags in conformance with the SGML specification.

The World Wide web consortium (W3C) developed XML to enable the expansion of Web technologies into the new domains of document processing and data interchange. XML is a subset of SGML. It is designed to e…

Getting Started with XML

Introduction Traditionally, organizations have conducted business on paper. Preprinted formats were most widely used to exchange information between businesses. As the number of transactions between different organizations increased over the years, there was a need for a more effective way of communicating and processing business data. Electronic Data Interchange (IDE) emerged as a result of this need. EDI refers to the process of exchanging documents in a standard format between two computer systems.

The two widely used EDI standards for transmitting data between computers are ANSI X12 and UN/EDIFACT. if data is transmitted using EDI standards, the data can be translated to or from the end-user's application format with the help of EDI software, such as RealWorld and Macola.

Consider an example of two companies, X and Y, using RealWorld and Macola, respectively to convert their files into EDI formats. Without an EDI standard, company Y cannot translate the EDI files received fro…

ASP.NET : Bind CheckBoxList with Multiple DataSource

Introduction The term DataSource means you can store multiple data at one place known as DataSource. There are different DataSource available in DOTNET library such as DataTable , SqlDataReader, Array , Collections etc. Now at time, lets take a simple example to bind single CheckBoxList with multiple DataSource.
 Algorithm behind the scene
Step-1 : Drop CheckBoxList and Two button control onto the design page.
Step-2 : On first button click event we can bind CheckBoxList with one string array
Step-3 : On Second button click event we can bind same CheckBoxList with another string array.
Complete Code<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default2.aspx.cs"Inherits="Default2"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"> <headrunat="server"> <title>Example o…

Programmatically change CheckBoxList enable disable property in ASP.NET

In previous example we have been covered public properties of CheckBoxList control such as
How to use CheckBoxList Control in ASP.NETASP.NET: Programmatically change CheckBoxList Background ColorHow to bind CheckBoxList using SqlDataSource in ASP.NETHow to Bind CheckBoxList in ASP.NETProgrammatically change CheckBoxList font name in ASP.NETASP.NET: Example of Programmatically change CheckBoxList Border color Lets take another example to be related to enable or disable property of CheckBoxList <%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default2.aspx.cs"Inherits="Default2"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"> <headrunat="server"> <title>Example of Enable disable property of CheckBoxList</title> <styletype="text/css"> .style1 { font-…

Programmatically change CheckBoxList font name in ASP.NET

CheckBoxList control is the collection of CheckBoxes . Now you can perform some operations on each CheckBox using Index. Application of CheckBoxList control.

You can select multiple items.
Complete code<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default2.aspx.cs"Inherits="Default2"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"> <headrunat="server"> <title>Change font name of the CheckBox List</title> </head> <body> <formid="form1"runat="server"> <div> <asp:CheckBoxListID="CheckBoxList1"runat="server"Width="168px"> <asp:ListItem>AdRotator Control</asp:ListItem> <asp:ListItem>BulletedList Control</asp:ListItem> <asp:ListItem>Button Control</asp:ListIte…