Skip to main content

Creating Dynamic Tables in Code Behind File

Create Panel in .aspx.......                                                23-Sep-2011
<asp:Panel ID="pnTable" runat="server">
    </asp:Panel>

Code Behind File......

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

public partial class DyanmicTable : System.Web.UI.Page
{
    string connection = Convert.ToString(ConfigurationManager.ConnectionStrings["Test"].ConnectionString);

    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(connection);
        SqlCommand sc = new SqlCommand("Test", conn);
        sc.CommandType = CommandType.StoredProcedure;
        conn.Open();
        SqlDataAdapter sd = new SqlDataAdapter(sc);
        DataSet ds = new DataSet();
        sd.Fill(ds);
        conn.Close();
        string count = ds.Tables[0].Rows[0]["count"].ToString();
        pnTable.Controls.Clear();
        int tblCols = Convert.ToInt32(count);
        Table tbl = new Table();
        pnTable.Controls.Add(tbl);
        for (int i = 0; i < tblCols; i++)
        {
            TableRow tr = new TableRow();
            TableCell tc = new TableCell();
            HyperLink hypTest = new HyperLink();
            hypTest .Text = ds.Tables[1].Rows[i]["Column Name"].ToString() + "" + "Accidents";
            hypTest .Font.Size = FontUnit.Small;
            //hypTest .ForeColor = System.Drawing.Color.Green;
            hypTest .Attributes["class"] = "test";
            hypTest .NavigateUrl = "http://www.Test.com" + ds.Tables[1].Rows[0]["Column Name"].ToString();
            tc.Controls.Add(hypTest );
            tr.Controls.Add(tc);
            tbl.Controls.Add(tr);
        }
    }
}







Store Procedure...

Create Procedure Test
as
begin
begin Transaction Test
    select COUNT(*) as count from Table Name
    select * from  Table Name
    order by Column Name
    if(@@ERROR !=0)
    Begin
        rollback transaction Test
        return
    end
        commit transaction Test
end

Comments

Popular posts from this blog

SQL Query :- Create Tables,Primary key,Foreign key,Merge Statment

SQL Query 1)    Using CASE Statement : - To Check the Particular column ISNULL              CASE WHEN ISNULL ([Col_Name], ' ') = ' ' THEN 'Others'                       ELSE [Col_Name] END AS [Col_Name] 2)    Convert Data format into VARCHAR and save 10/18/2012 this Format and also check if Date Column is Empty or not.                 CONVERT (VARCHAR,[Col_CreatedDt], 101) AS CreatedDt                        , CASE WHEN ISNULL ([Col_ModifiedDt], ' ') = ' ' THEN ' not available'                        ELSE CONVERT (VARCHAR, [ Col_ModifiedDt], 101) END AS ModifiedDt 3)    Casting  and Check Date Difference               CAST (Col_Name or ParameterName AS VARCHAR)               DATEDIFF(HOUR,Col_Date, GETDATE())<=24 4)    Create two table and set Primary key and Foreign Key             Create Table Exams            (                 exam_id int primary key,                 exam_name varchar(50),            );    

AngularJS

What is AngularJS? AngularJS is an open source web application framework. It was originally developed in 2009 by Misko Hevery and Adam Abrons. It is now maintained by Google. Its latest version is 1.4.3. Definition of AngularJS as put by its  official documentation  is as follows − AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. Angular's data binding and dependency injection eliminate much of the code you currently have to write. And it all happens within the browser, making it an ideal partner with any server technology. Features AngularJS is a powerful JavaScript based development framework to create RICH Internet Application(RIA). AngularJS provides developers options to write client side application (using JavaScript) in a clean MVC(Model View Controller) way. Application written in AngularJS is c

GridView Design Using CSS

 Create Css File in your Project...And Add Reference to Grid View page * {     padding: 0;     margin: 0; } body {     font: 11px Tahoma;     background-color: #F7F7E9; } h1 {     font: bold 32px Times;     color: #666;     text-align: center;     padding: 20px 0;    } #container {     width: 700px;     margin: 10px auto; } .mGrid  {     width: 100%;     background-color: #fff;     margin: 5px 0 10px 0;     border: solid 1px #525252;     border-collapse:collapse; } .mGrid td {    padding: 2px;    border: solid 1px #c1c1c1;    color: #717171; } .mGrid th {     padding: 4px 2px;     color: #fff;     background: #424242 url(grd_head.png) repeat-x top;     border-left: solid 1px #525252;     font-size: 0.9em; } .mGrid .alt {     background: #fcfcfc url(grd_alt.png) repeat-x top; } .mGrid .pgr {     background: #424242 url(grd_pgr.png) repeat-x top; } .mGrid .pgr table {     margin: 5px 0; } .mGrid .pgr td {     border-width: 0;     p