programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Friday, August 29, 2014

Dynamically Create Temporary Table in

Dynamically Create Temporary Table in using C#:

In this post we describe working with c# code and create tem or temporary table in using C# code. It is very simple to make HTML controls or web controls before running a Web Page. In Just Drag and Drop from Toolbox menu or write ASP code for that web Page (abc.aspx). But some time we think that generating HTML controls or controls are difficult during runtime.

Dynamically Temporary Table creation in

Here we give a segment of code in this we make an table (data table) by C# code.
Create Temporary Table by C# in

DataTable dt = new DataTable();

Create the object of datatable

        dt.Columns.Add("Cost_Id", typeof(Int32));
        dt.Columns.Add("Name", typeof(string));
        dt.Columns.Add("Address", typeof(string));

Add column in data table object. And last fill the values in these columns.

        dt.Rows.Add(1, "Parijat", "India");

Using C# code Create a Table Dynamically in ASP.NET:

Temporary tablebyCsharp.aspx code Example:

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <title>Creating a temp table in using c#</title>
    <form id="form1" runat="server">
    <div align="center">
            Example of Creating a temp data table in using c#</h1>
        <br />
        <%--Take a grid control and bind this control by dymanic created table.--%>
        <asp:GridView ID="gird1" runat="server" Height="236px" Width="462px">
            <HeaderStyle BackColor="Maroon" Font-Bold="true" ForeColor="White" />

C# code on table by Csharp.aspx.cs for create table:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class tablebyCsharp : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        DataTable dt = new DataTable();

        //create colums here.
        dt.Columns.Add("Cost_Id", typeof(Int32));
        dt.Columns.Add("Name", typeof(string));
        dt.Columns.Add("Address", typeof(string));

        //fill the value in colums by row.
        dt.Rows.Add(1, "Parijat", "India");
        dt.Rows.Add(2, "Roz", "U.S.A");
        dt.Rows.Add(3, "Maqsood", "U.P.");
        dt.Rows.Add(4, "Parvez", "Pakistan");
        dt.Rows.Add(6, "Tinny", "Japan");
        dt.Rows.Add(7, "Mr. Song", "Chine");

       //bind dymanic created table in grid.
        gird1.DataSource = dt;
Dynamically Create Temporary Table in
 Temporary Table in

Other Related Post on this tutorial:

·          How to Bind Gridview Form database.

No comments:

Post a Comment