How to display datas in a gridview in asp.net.


 
 
 data is taking from table table_3

        protected void Page_Load(object sender, EventArgs e)
        {
             SqlCommand MyCommand;  
            SqlDataAdapter MyAdapter;  
            DataTable MyTable;
            SqlConnection MyConnection;
            MyConnection = new SqlConnection();
            MyConnection.ConnectionString =
"Data   Source=B406DCOK;Initial     Catalog=Akhil;Integrated  Security=True";  

            MyCommand = new SqlCommand();  
            MyCommand.CommandText = "select * from Table_3";  
            MyCommand.CommandType = CommandType.Text;  
            MyCommand.Connection = MyConnection;
          
          
            MyTable = new DataTable();  
            MyAdapter = new SqlDataAdapter();  
            MyAdapter.SelectCommand = MyCommand;  
            MyAdapter.Fill(MyTable);  
 
            GridView1.DataSource = MyTable.DefaultView;  
            GridView1.DataBind();
            GridView2.DataSource = MyTable.DefaultView;
            GridView2.DataBind();
           
      }

Comments

Popular posts from this blog

Introduction To Oracle10g

Insert

Except