Skip to main content

Posts

Showing posts from October, 2013

Featured Post

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

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 : DataGridViewButtonColumn Header 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 da

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 ex

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;     

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 paging DataSet ds = new DataSet ();         SqlDataAdapter da = new SqlDataAdapter (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

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 receive

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 <% @ Page Language ="C#" AutoEventWireup ="true" CodeFile ="Default2.aspx.cs" Inherits ="Default2" %> <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < html xmlns ="http://www.w3.org/1999/xhtml">

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.NET ASP.NET: Programmatically change CheckBoxList Background Color How to bind CheckBoxList using SqlDataSource in ASP.NET   How to Bind CheckBoxList in ASP.NET Programmatically change CheckBoxList font name in ASP.NET ASP.NET: Example of Programmatically change CheckBoxList Border color Lets take another example to be related to enable or disable property of CheckBoxList <% @ Page Language ="C#" AutoEventWireup ="true" CodeFile ="Default2.aspx.cs" Inherits ="Default2" %> <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < html xmlns ="http://www.w3.org/1999/xhtml"> < head runat ="server">     < title > Example of Enable disable property o

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 <% @ Page Language ="C#" AutoEventWireup ="true" CodeFile ="Default2.aspx.cs" Inherits ="Default2" %> <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < html xmlns ="http://www.w3.org/1999/xhtml"> < head runat ="server">     < title > Change font name of the CheckBox List </ title > </ head > < body >     < form id ="form1" runat ="server">     < div >         < asp : CheckBoxList ID ="CheckBoxList1" runat ="server" Width ="168px">             < asp : ListItem >