Showing posts with label LOW CREDIT LINE CREDIT CARDS. Show all posts
Showing posts with label LOW CREDIT LINE CREDIT CARDS. Show all posts

Wednesday, April 9, 2014

Dynamic Grid View

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

<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>
    <tr>
    <td>
    <asp:GridView ID="grdview" runat="server" AutoGenerateColumns="false">
    <Columns>
    <asp:TemplateField HeaderText="Region">
    <ItemTemplate>
    <asp:Label ID="lbl" runat="server" Text='<%#bind("region") %>'> </asp:Label>
 
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
 
 
 
    </asp:GridView>
    </td>
    </tr>
    </table>
 
    </div>
    </form>
</body>
</html>
-----------------------------------------------------------------------------------------------------------
aspx.cs

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

public partial class Griddynamic : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Class1 obj = new Class1();
        grdview.DataSource = obj.getgrid();
        grdview.DataBind();

    }
}
----------------------------------------------------------------------------------------------------------------------------------

Class1.CS 
 public DataSet getgrid()
    {
        SqlConnection con = new SqlConnection(aaa);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandText = "sp_grid";
        cmd.CommandType = CommandType.StoredProcedure;
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        con.Close();
        return ds;
    }