Grid View in ASP.NET
- Create a new website in visual studio 2005/2008
- Select a file location and file name and language.
- Create some text boxes with name in web form
Example:

Now drag a grid view in web form and click the edit column property show in figure and add the item inside the grid view .You can also change it format by using property Auto Format.

Now choose the data source and click on ok button.

Now click on New Connection and then click on

Choose either Window or server authentication, server name and attach the database. Click on ok button


Now Click next

Further Click next

Click next and test Query and click finish
Now use the Defalut.aspx.cs page and add the following codeusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page{
SqlConnection con;
SqlCommand cmd
string str;
SqlDataAdapter ad;
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection ("Data Source =server name;Initial Catalog=Database Name";User ID= User;Password = your PasswordRecovery");
con.Open();
Response.Write("connect");
}
protected void Button1_Click(object sender, EventArgs e)
{
str = "select * from empinfo where name ='"+TextBox1.Text+"' ,address = '"+TextBox2.Text+"',email_id ='"+TextBox3.Text+"'";
ad =new SqlDataAdapter (str,con);
GridView1.DataSource =ds.tables [empinfo].defaultview;
GridView1.DataMember ="empinfo";
GridView1 .DataBind ();
}

xxx yyyPosted Jul 13, 2010, 1:25 PM
hello i have to create a solution for my school and in your solutions i´m not understand what ds means. One part of my project i need to do the same o did in this solutions Regrets i hope you answer me.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>