What is the Dataset in ASP.NET

Share it Please

Introduction: -

Here I will explain what is Dataset and uses of Dataset with example in asp.net using C# .


In previous posts I explained What is Cloud Computing , Difference between .NET Framework 4.5 and .NET Framework 4.0, Basics of ASP.NET. Now I will explain what is Dataset and uses of Dataset with example in asp.net using c# .

What Is Dataset?
A dataset (or data set) is a collection of data.
Most commonly a dataset corresponds to the contents of a single database table, or a single statistical data matrix, where each column of the table represents a particular variable, and each row corresponds to a given member of the dataset in question. The dataset lists values for each of the variables, such as height and weight of an object, for each member of the dataset. Each value is known as a datum. The dataset may comprise data for one or more members, corresponding to the number of rows.

The term dataset may also be used more loosely, to refer to the data in a collection of closely related tables, corresponding to a particular experiment or event.

C# Specifications for code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using Arahan;

public partial class testing : System.Web.UI.Page
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
    SqlCommand cmd = new SqlCommand();
    DataFill d = new DataFill();

    protected void Page_Load(object sender, EventArgs e)
    public void fillgrd()
        DataSet dst = new DataSet();
        DataTable dt = new DataTable("People");
        dt.Rows.Add("1","Amit Singh","21");
        DataTable ds = new DataTable("new People");
        ds.Rows.Add("1", "Amitendra", "21");
        ds.Rows.Add("2", "Amit Singh", "21");


        dst.Tables["new People"].Rows[0][0].ToString();
        GridView1.DataSource = dst.Tables["new People"];


ASPX Code Using Grid View:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testing.aspx.cs" Inherits="testing" %>

<!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">
    <style type="text/css">
            width: 100%;
    <form id="form1" runat="server">
        <table class="style1">
                <td align="center"
                    style="font-family: verdana; font-size: medium; font-weight: normal; font-style: normal; font-variant: normal; text-transform: none; color: #FFFFFF; background-color: #006699">
                    DataSet Entry</td>
                <td align="left"
                    style="font-family: verdana; font-size: small; font-weight: normal; font-style: normal; font-variant: normal; text-transform: none; color: #006699">
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                        BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
                        <FooterStyle BackColor="White" ForeColor="#000066" />
                        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                        <RowStyle ForeColor="#000066" />
                        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                        <SortedAscendingCellStyle BackColor="#F1F1F1" />
                        <SortedAscendingHeaderStyle BackColor="#007DBB" />
                        <SortedDescendingCellStyle BackColor="#CAC9C9" />
                        <SortedDescendingHeaderStyle BackColor="#00547E" />
                        <asp:TemplateField HeaderText="ID">
                        <ItemTemplate><asp:Label ID="lbl_id" runat="server" Text='<%#Eval("id") %>'></asp:Label></ItemTemplate>
                        <asp:TemplateField HeaderText="Name">
                        <asp:Label ID="lbl_nme" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
                        <asp:TemplateField HeaderText="Age">
                        <asp:Label ID="lbl_age" runat="server" Text='<%#Eval("Age") %>'></asp:Label>



Subscribe via email

Enter your email address:

Delivered by FeedBurner