using System;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Data.SqlClient;using System.Data.Sql;using System.Data;using EO.Web;using EO.Web.Internal;
public partial class _Default : System.Web.UI.Page { public static string connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\mshamanna\My Documents\Visual Studio 2010\WebSites\EOTest2\App_Data\Database.mdf;Integrated Security=True;User Instance=True";
protected void Page_Load(object sender, System.EventArgs e) { string sql = @"select * from Temp"; SqlConnection conn = new SqlConnection(connectionString); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd = new SqlCommand(sql, conn); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds, "Temp"); Grid1.DataSource = ds.Tables[0]; Grid1.DataBind(); }
//To Save grid values into database protected void btnSave_Click(object sender, System.EventArgs e) { string header3 = ""; int id = 0;
SqlConnection conn = new SqlConnection(connectionString); conn.Open(); int count = 0;
foreach (EO.Web.GridItem item in Grid 1.Items) { count++; //Get the cell value in the second column header3 = (string)item.Cells[2].Value; string sql = @"UPDATE TEMP SET HEADER3='" + header3 + "' WHERE ID='" + count + "'";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
}
conn.Close()
---------------------