<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" EnableEventValidation="false" Inherits="_Default" %>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data.SqlClient;
using System.Data;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
SqlConnection con = null;
protected void Page_Load(object sender, EventArgs e)
{
try
{
con = new SqlConnection("Data Source=; Integrated Security=false; Initial Catalog=test; User ID=; Password=");
dataBind();
}
catch (Exception m) { Response.Write("Connection can not Establishing
"+m.Message); }
}
public void dataBind()
{
try
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from GridView", con);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
}
con.Close();
}
catch (Exception e) { Response.Write(e.Message); }
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
dataBind();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
dataBind();
}
}

Dorababu MekaPosted Dec 28, 2012, 7:23 AM
con = new SqlConnection("Data Source=iagentserver; Integrated Security=false; Initial Catalog=test; User ID=sa; Password=iAgent123");
protected void Page_Load(object sender, EventArgs e)
{
if(!ispostback)
{
try
{
dataBind();
}
catch (Exception m) { Response.Write("Connection can not Establishing
"+m.Message); }
}
}