Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
my code is....

C#
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;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection cn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\MANTHAN\\Documents\\Visual Studio 2010\\WebSites\\sample\\App_Data\\Database.mdf;Integrated Security=True;User Instance=True");
        cn.Open();
        SqlCommand cmd = new SqlCommand("SELECT * FROM stu1", cn);
        SqlDataAdapter adp = new SqlDataAdapter();
      
       
        DataSet ds = new DataSet();
        

        adp.Fill(ds);
        cn.Close();
        
        GridView1.DataSource = ds.Tables[0];


    }
}
Posted
Updated 11-Jun-13 20:47pm
v2
Comments
OriginalGriff 12-Jun-13 2:34am    
Please do not repost your question to add information: use the "Improve Question"widget instead.
I have deleted the older version.

1 solution

Try this.

C#
SqlDataAdapter adp = new SqlDataAdapter(cmd);
 
Share this answer
 
Comments
manthan11 12-Jun-13 8:28am    
data is not display on gridview when run a page......

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900