| Home | Forums | Reviews | Articles | Register |
![]() |
| Thread Tools |
Rating:
|
|
|
|
| |
|
=?Utf-8?B?QmlsbCBCb3Jn?=
Guest
Posts: n/a
|
After the update, are you refreshing the datagrid--i.e. myGrid.DataSource = myDataSet and myGrid.DataBind()
Bill Borg |
|
||
|
||||
|
Mervin Williams
Guest
Posts: n/a
|
Yes, I do make those two calls. But, still the values are not refreshed.
Mervin Williams ================================================ "Bill Borg" <(E-Mail Removed)> wrote in message news:0329C75A-6815-4CE9-830E-(E-Mail Removed)... > After the update, are you refreshing the datagrid--i.e. myGrid.DataSource = myDataSet and myGrid.DataBind()? > > Bill Borg |
|
||
|
||||
|
Mervin Williams
Guest
Posts: n/a
|
Okay, here is my webform code:
========================================================== using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using Infragistics.WebUI.Shared; using System.Data.SqlClient; using System.Data.SqlTypes; using System.Configuration; using System.Text; using System.Diagnostics; using OFS.Template; namespace OFS { /// <summary> /// Summary description for ClientCreateAgmt. /// </summary> public class ClientCreateAgmt : System.Web.UI.Page { #region Declarations protected System.Web.UI.WebControls.TextBox txtName; protected System.Web.UI.WebControls.TextBox txtAddress_line1; protected System.Web.UI.WebControls.TextBox txtAddress_line2; protected System.Web.UI.WebControls.TextBox txtCity; protected System.Web.UI.WebControls.TextBox txtState; protected System.Web.UI.WebControls.TextBox txtZip; protected System.Web.UI.WebControls.TextBox txtPhone1; protected System.Web.UI.WebControls.TextBox txtFax; protected System.Web.UI.WebControls.TextBox txtDuns; protected System.Web.UI.WebControls.TextBox txtSic_no; protected System.Web.UI.WebControls.TextBox txtLine_of_business; protected System.Web.UI.WebControls.TextBox txtDb_rating; protected System.Web.UI.WebControls.Button btnApply; protected System.Web.UI.WebControls.Button btnSave; protected System.Data.SqlClient.SqlDataAdapter daCompany; protected System.Web.UI.HtmlControls.HtmlTable Table2; private int retVal1, retVal2, retVal3, retVal4; private bool insertMode = false; protected PageBody pbdTemplate; protected System.Web.UI.WebControls.Label lblMessage; protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1; protected System.Data.SqlClient.SqlCommand sqlSelectCommand3; protected System.Data.SqlClient.SqlCommand sqlInsertCommand3; protected System.Data.SqlClient.SqlCommand sqlUpdateCommand3; protected System.Data.SqlClient.SqlCommand sqlDeleteCommand3; protected System.Data.SqlClient.SqlDataAdapter daContact; protected OFS.dsCompanyInfo dsCompanyInfo; protected System.Data.SqlClient.SqlConnection cnCompanyInfo; protected System.Data.SqlClient.SqlCommand sqlSelectCommand1; protected System.Data.SqlClient.SqlCommand sqlInsertCommand1; protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1; protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1; int companyid; protected System.Web.UI.WebControls.TextBox TextBox2; protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.DataGrid DataGrid1; int userID; #endregion private void Page_Load(object sender, System.EventArgs e) { userID = Convert.ToInt32(Context.User.Identity.Name); try { // Retrieve company data retVal1 = daCompany.Fill(dsCompanyInfo); retVal3 = daContact.Fill(dsCompanyInfo); } catch(Exception ex) { Debug.WriteLine("DataSet errors: " + dsCompanyInfo.DataSetName); foreach (DataTable table in dsCompanyInfo.Tables) { DataRow[] errorRows; errorRows = table.GetErrors(); foreach (DataRow row in errorRows) { Debug.WriteLine("Table: " + table.TableName); Debug.WriteLine("Row Error: " + row.RowError); DataColumn[] errorColumns; errorColumns = row.GetColumnsInError(); foreach (DataColumn column in errorColumns) { Debug.WriteLine("Column: " + column.ColumnName); Debug.WriteLine("Error: " + row.GetColumnError(column)); } } } } // Filter Company dataview in the dataset by userid // dsCompanyInfo.Tables["Company_User"].DefaultView.RowFilter = "companyid = " + 3; dsCompanyInfo.DefaultViewManager.DataViewSettings["Company"].RowFilter = "UserID = " + userID; dsCompanyInfo.DefaultViewManager.DataViewSettings["Contact"].RowFilter = "UserID = " + userID; // dataView1.RowFilter = "UserID = " + userID; // If data available exists bind data if(retVal1 > 0 && retVal3 > 0) { if(!IsPostBack) DataBind(); } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader(); this.daCompany = new System.Data.SqlClient.SqlDataAdapter(); this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand(); this.cnCompanyInfo = new System.Data.SqlClient.SqlConnection(); this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand(); this.sqlSelectCommand3 = new System.Data.SqlClient.SqlCommand(); this.sqlInsertCommand3 = new System.Data.SqlClient.SqlCommand(); this.sqlUpdateCommand3 = new System.Data.SqlClient.SqlCommand(); this.sqlDeleteCommand3 = new System.Data.SqlClient.SqlCommand(); this.daContact = new System.Data.SqlClient.SqlDataAdapter(); this.dsCompanyInfo = new OFS.dsCompanyInfo(); ((System.ComponentModel.ISupportInitialize)(this.dsCompanyInfo)).BeginInit() ; this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelC ommand); this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCom mand); this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateC ommand); this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // daCompany // this.daCompany.DeleteCommand = this.sqlDeleteCommand1; this.daCompany.InsertCommand = this.sqlInsertCommand1; this.daCompany.SelectCommand = this.sqlSelectCommand1; this.daCompany.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "Company", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("company_id", "company_id"), new System.Data.Common.DataColumnMapping("name", "name"), new System.Data.Common.DataColumnMapping("address_line1", "address_line1"), new System.Data.Common.DataColumnMapping("address_line2", "address_line2"), new System.Data.Common.DataColumnMapping("address_line3", "address_line3"), new System.Data.Common.DataColumnMapping("city", "city"), new System.Data.Common.DataColumnMapping("state", "state"), new System.Data.Common.DataColumnMapping("zip", "zip"), new System.Data.Common.DataColumnMapping("phone1", "phone1"), new System.Data.Common.DataColumnMapping("fax", "fax"), new System.Data.Common.DataColumnMapping("duns", "duns"), new System.Data.Common.DataColumnMapping("sic_no", "sic_no"), new System.Data.Common.DataColumnMapping("line_of_business", "line_of_business"), new System.Data.Common.DataColumnMapping("db_rating", "db_rating")})}); this.daCompany.UpdateCommand = this.sqlUpdateCommand1; // // sqlDeleteCommand1 // this.sqlDeleteCommand1.CommandText = @"DELETE FROM Company WHERE (company_id = @Original_company_id) AND (address_line1 = @Original_address_line1 OR @Original_address_line1 IS NULL AND address_line1 IS NULL) AND (address_line2 = @Original_address_line2 OR @Original_address_line2 IS NULL AND address_line2 IS NULL) AND (address_line3 = @Original_address_line3 OR @Original_address_line3 IS NULL AND address_line3 IS NULL) AND (city = @Original_city OR @Original_city IS NULL AND city IS NULL) AND (db_rating = @Original_db_rating OR @Original_db_rating IS NULL AND db_rating IS NULL) AND (duns = @Original_duns OR @Original_duns IS NULL AND duns IS NULL) AND (fax = @Original_fax OR @Original_fax IS NULL AND fax IS NULL) AND (line_of_business = @Original_line_of_business OR @Original_line_of_business IS NULL AND line_of_business IS NULL) AND (name = @Original_name OR @Original_name IS NULL AND name IS NULL) AND (phone1 = @Original_phone1 OR @Original_phone1 IS NULL AND phone1 IS NULL) AND (sic_no = @Original_sic_no OR @Original_sic_no IS NULL AND sic_no IS NULL) AND (state = @Original_state OR @Original_state IS NULL AND state IS NULL) AND (zip = @Original_zip OR @Original_zip IS NULL AND zip IS NULL)"; this.sqlDeleteCommand1.Connection = this.cnCompanyInfo; this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_company_id", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "company_id", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_address_line1", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "address_line1", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_address_line2", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "address_line2", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_address_line3", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "address_line3", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_city", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "city", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_db_rating", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "db_rating", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_duns", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "duns", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_fax", System.Data.SqlDbType.VarChar, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "fax", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_line_of_business", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "line_of_business", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_name", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "name", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_phone1", System.Data.SqlDbType.VarChar, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "phone1", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_sic_no", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "sic_no", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_state", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "state", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_zip", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "zip", System.Data.DataRowVersion.Original, null)); // // cnCompanyInfo // this.cnCompanyInfo.ConnectionString = ((string)(configurationAppSettings.GetValue("OFS.ConnectionString", typeof(string)))); // // sqlInsertCommand1 // this.sqlInsertCommand1.CommandText = @"INSERT INTO Company(name, address_line1, address_line2, address_line3, city, state, zip, phone1, fax, duns, sic_no, line_of_business, db_rating) VALUES (@name, @address_line1, @address_line2, @address_line3, @city, @state, @zip, @phone1, @fax, @duns, @sic_no, @line_of_business, @db_rating)"; this.sqlInsertCommand1.Connection = this.cnCompanyInfo; this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.VarChar, 50, "name")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@address_line1", System.Data.SqlDbType.VarChar, 50, "address_line1")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@address_line2", System.Data.SqlDbType.VarChar, 50, "address_line2")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@address_line3", System.Data.SqlDbType.VarChar, 50, "address_line3")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@city", System.Data.SqlDbType.VarChar, 50, "city")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@state", System.Data.SqlDbType.VarChar, 2, "state")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@zip", System.Data.SqlDbType.VarChar, 50, "zip")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@phone1", System.Data.SqlDbType.VarChar, 15, "phone1")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@fax", System.Data.SqlDbType.VarChar, 15, "fax")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@duns", System.Data.SqlDbType.VarChar, 50, "duns")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@sic_no", System.Data.SqlDbType.VarChar, 50, "sic_no")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@line_of_business", System.Data.SqlDbType.VarChar, 50, "line_of_business")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@db_rating", System.Data.SqlDbType.VarChar, 50, "db_rating")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@userid", System.Data.SqlDbType.Int, 4, "UserID")); this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@company_id", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "company_id", System.Data.DataRowVersion.Current, null)); // // sqlSelectCommand1 // this.sqlSelectCommand1.CommandText = @"SELECT Company.company_id, Company.name, Company.address_line1, Company.address_line2, Company.address_line3, Company.city, Company.state, Company.zip, Company.phone1, Company.fax, Company.duns, Company.sic_no, Company.line_of_business, Company.db_rating, Company_User.UserID AS UserID FROM Company INNER JOIN Company_User ON Company.company_id = Company_User.company_id"; this.sqlSelectCommand1.Connection = this.cnCompanyInfo; // // sqlUpdateCommand1 // this.sqlUpdateCommand1.CommandText = @"UPDATE Company SET name = @name, address_line1 = @address_line1, address_line2 = @address_line2, address_line3 = @address_line3, city = @city, state = @state, zip = @zip, phone1 = @phone1, fax = @fax, duns = @duns, sic_no = @sic_no, line_of_business = @line_of_business, db_rating = @db_rating WHERE (company_id = @Original_company_id) AND (address_line1 = @Original_address_line1 OR @Original_address_line1 IS NULL AND address_line1 IS NULL) AND (address_line2 = @Original_address_line2 OR @Original_address_line2 IS NULL AND address_line2 IS NULL) AND (address_line3 = @Original_address_line3 OR @Original_address_line3 IS NULL AND address_line3 IS NULL) AND (city = @Original_city OR @Original_city IS NULL AND city IS NULL) AND (db_rating = @Original_db_rating OR @Original_db_rating IS NULL AND db_rating IS NULL) AND (duns = @Original_duns OR @Original_duns IS NULL AND duns IS NULL) AND (fax = @Original_fax OR @Original_fax IS NULL AND fax IS NULL) AND (line_of_business = @Original_line_of_business OR @Original_line_of_business IS NULL AND line_of_business IS NULL) AND (name = @Original_name OR @Original_name IS NULL AND name IS NULL) AND (phone1 = @Original_phone1 OR @Original_phone1 IS NULL AND phone1 IS NULL) AND (sic_no = @Original_sic_no OR @Original_sic_no IS NULL AND sic_no IS NULL) AND (state = @Original_state OR @Original_state IS NULL AND state IS NULL) AND (zip = @Original_zip OR @Original_zip IS NULL AND zip IS NULL)"; this.sqlUpdateCommand1.Connection = this.cnCompanyInfo; this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@name", System.Data.SqlDbType.VarChar, 50, "name")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@address_line1", System.Data.SqlDbType.VarChar, 50, "address_line1")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@address_line2", System.Data.SqlDbType.VarChar, 50, "address_line2")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@address_line3", System.Data.SqlDbType.VarChar, 50, "address_line3")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@city", System.Data.SqlDbType.VarChar, 50, "city")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@state", System.Data.SqlDbType.VarChar, 2, "state")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@zip", System.Data.SqlDbType.VarChar, 50, "zip")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@phone1", System.Data.SqlDbType.VarChar, 15, "phone1")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@fax", System.Data.SqlDbType.VarChar, 15, "fax")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@duns", System.Data.SqlDbType.VarChar, 50, "duns")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@sic_no", System.Data.SqlDbType.VarChar, 50, "sic_no")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@line_of_business", System.Data.SqlDbType.VarChar, 50, "line_of_business")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@db_rating", System.Data.SqlDbType.VarChar, 50, "db_rating")); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_company_id", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "company_id", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_address_line1", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "address_line1", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_address_line2", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "address_line2", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_address_line3", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "address_line3", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_city", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "city", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_db_rating", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "db_rating", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_duns", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "duns", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_fax", System.Data.SqlDbType.VarChar, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "fax", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_line_of_business", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "line_of_business", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_name", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "name", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_phone1", System.Data.SqlDbType.VarChar, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "phone1", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_sic_no", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "sic_no", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_state", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "state", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_zip", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "zip", System.Data.DataRowVersion.Original, null)); // // sqlSelectCommand3 // this.sqlSelectCommand3.CommandText = "SELECT Contact.contact_id, Contact.firstname, Contact.lastname, Contact.title, Co" + "ntact.phone, Company_User.UserID FROM Contact CROSS JOIN Company_User"; this.sqlSelectCommand3.Connection = this.cnCompanyInfo; // // sqlInsertCommand3 // this.sqlInsertCommand3.CommandText = "INSERT INTO Contact(firstname, lastname, title, phone) VALUES (@firstname, @lastn" + "ame, @title, @phone); SELECT contact_id, firstname, lastname, title, phone FROM " + "Contact WHERE (contact_id = @@IDENTITY)"; this.sqlInsertCommand3.Connection = this.cnCompanyInfo; this.sqlInsertCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@firstname", System.Data.SqlDbType.VarChar, 50, "firstname")); this.sqlInsertCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@lastname", System.Data.SqlDbType.VarChar, 50, "lastname")); this.sqlInsertCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@title", System.Data.SqlDbType.VarChar, 50, "title")); this.sqlInsertCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@phone", System.Data.SqlDbType.VarChar, 15, "phone")); // // sqlUpdateCommand3 // this.sqlUpdateCommand3.CommandText = @"UPDATE Contact SET firstname = @firstname, lastname = @lastname, title = @title, phone = @phone WHERE (contact_id = @Original_contact_id) AND (firstname = @Original_firstname OR @Original_firstname IS NULL AND firstname IS NULL) AND (lastname = @Original_lastname OR @Original_lastname IS NULL AND lastname IS NULL) AND (phone = @Original_phone) AND (title = @Original_title OR @Original_title IS NULL AND title IS NULL); SELECT contact_id, firstname, lastname, title, phone FROM Contact WHERE (contact_id = @contact_id)"; this.sqlUpdateCommand3.Connection = this.cnCompanyInfo; this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@firstname", System.Data.SqlDbType.VarChar, 50, "firstname")); this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@lastname", System.Data.SqlDbType.VarChar, 50, "lastname")); this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@title", System.Data.SqlDbType.VarChar, 50, "title")); this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@phone", System.Data.SqlDbType.VarChar, 15, "phone")); this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_contact_id", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "contact_id", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_firstname", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "firstname", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_lastname", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "lastname", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_phone", System.Data.SqlDbType.VarChar, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "phone", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_title", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "title", System.Data.DataRowVersion.Original, null)); this.sqlUpdateCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@contact_id", System.Data.SqlDbType.Int, 4, "contact_id")); // // sqlDeleteCommand3 // this.sqlDeleteCommand3.CommandText = @"DELETE FROM Contact WHERE (contact_id = @Original_contact_id) AND (firstname = @Original_firstname OR @Original_firstname IS NULL AND firstname IS NULL) AND (lastname = @Original_lastname OR @Original_lastname IS NULL AND lastname IS NULL) AND (phone = @Original_phone) AND (title = @Original_title OR @Original_title IS NULL AND title IS NULL)"; this.sqlDeleteCommand3.Connection = this.cnCompanyInfo; this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_contact_id", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "contact_id", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_firstname", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "firstname", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_lastname", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "lastname", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_phone", System.Data.SqlDbType.VarChar, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "phone", System.Data.DataRowVersion.Original, null)); this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_title", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "title", System.Data.DataRowVersion.Original, null)); // // daContact // this.daContact.DeleteCommand = this.sqlDeleteCommand3; this.daContact.InsertCommand = this.sqlInsertCommand3; this.daContact.SelectCommand = this.sqlSelectCommand3; this.daContact.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] { new System.Data.Common.DataTableMapping("Table", "Contact", new System.Data.Common.DataColumnMapping[] { new System.Data.Common.DataColumnMapping("contact_id", "contact_id"), new System.Data.Common.DataColumnMapping("firstname", "firstname"), new System.Data.Common.DataColumnMapping("lastname", "lastname"), new System.Data.Common.DataColumnMapping("title", "title"), new System.Data.Common.DataColumnMapping("phone", "phone")})}); this.daContact.UpdateCommand = this.sqlUpdateCommand3; // // dsCompanyInfo // this.dsCompanyInfo.DataSetName = "dsCompanyInfo"; this.dsCompanyInfo.EnforceConstraints = false; this.dsCompanyInfo.Locale = new System.Globalization.CultureInfo("en-US"); this.Load += new System.EventHandler(this.Page_Load); ((System.ComponentModel.ISupportInitialize)(this.dsCompanyInfo)).EndInit(); } #endregion private void btnSave_Click(object sender, System.EventArgs e) { if (Context.User.Identity.IsAuthenticated) { daCompany.Update(dsCompanyInfo); daCompany.Fill(dsCompanyInfo); if (daCompany.InsertCommand.Parameters["@company_id"].Value != null) { companyid = (int)daCompany.InsertCommand.Parameters["@company_id"].Value; } daContact.Update(dsCompanyInfo); } } private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { DataGrid1.EditItemIndex = e.Item.ItemIndex; DataGrid1.DataBind(); } private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { // Gets the value of the key field of the row being updated string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString(); // Gets get the value of the controls (textboxes) that the user // updated. The DataGrid columns are exposed as the Cells collection. // Each cell has a collection of controls. In this case, there is only // one control in each cell -- a TextBox control. To get its value, // you copy the TextBox to a local instance (which requires casting) // and extract its Text property. // // The first column -- Cells(0) -- contains the Update and Cancel buttons. string newFirstName, newLastName, newTitle, newPhone; TextBox box; // Gets the value of the tbFirstName TextBox control in the 2nd column box = (TextBox)(e.Item.Cells[1].FindControl("tbFirstName")); newFirstName = box.Text; // Gets the value of the tbLastName TextBox control in the 3rd column box = (TextBox)(e.Item.Cells[2].FindControl("tbLastName")); newLastName = box.Text; // Gets the value of the tbTitle TextBox control in the 3rd column box = (TextBox)(e.Item.Cells[3].FindControl("tbTitle")); newTitle = box.Text; // Gets the value of the tbPhone TextBox control in the 4th column box = (TextBox)(e.Item.Cells[4].FindControl("tbPhone")); newPhone = box.Text; // Finds the row in the dataset table that matches the // one the user updated in the grid. It uses a // special Find method defined for the typed dataset, which // returns a reference to the row. dsCompanyInfo.ContactRow rowToUpdate; rowToUpdate = dsCompanyInfo.Contact.FindBycontact_id(int.Parse(key)); // Updates the dataset table. rowToUpdate.firstname = newFirstName; rowToUpdate.lastname = newLastName; rowToUpdate.title = newTitle; rowToUpdate.phone = newPhone; // Calls a SQL statement to update the database from the dataset daContact.Update(dsCompanyInfo); // daContact.Update(new DataRow[] {rowToUpdate}); // Takes the DataGrid row out of editing mode DataGrid1.EditItemIndex = -1; // Refreshes the grid DataGrid1.DataBind(); Debug.WriteLine("Dataset phone value: " + dsCompanyInfo.Contact.FindBycontact_id(int.Parse(key)).phone); } private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { DataGrid1.EditItemIndex = -1; DataGrid1.DataBind(); } } } ========================================================== .. . . and here is my html code: ========================================================== <%@ Page language="c#" Codebehind="ClientCreateAgmt.aspx.cs" AutoEventWireup="false" Inherits="OFS.ClientCreateAgmt" %> <%@ Register TagPrefix="iglbar" Namespace="Infragistics.WebUI.UltraWebListbar" Assembly="Infragistics.WebUI.UltraWebListbar.v2" %> <%@ Register TagPrefix="gftp" NameSpace="OFS.Template" Assembly="OFS" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>Create Agreement</title> <LINK href="Style/iestyle.css" type="text/css" rel="stylesheet"> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> </HEAD> <body> <form id="Form1" method="post" runat="server"> <gftp agebody id="pbdTemplate" runat="server" pagetitle="CreateAgreement" templatepath="Template/ClientTemplate.ascx"> <asp:PlaceHolder id="PlaceHolder1" runat="server"> <asp:Label id="lblMessage" runat="server" Visible="False" ForeColor="Red">Label</asp:Label> </asp:PlaceHolder> <P></P> <TABLE id="Table2" cellSpacing="0" cellPadding="5" width="300" border="0" runat="server"> <TR> <TD style="WIDTH: 113px" align="right"></TD> <TD style="WIDTH: 457px"> <DIV align="center"> <DIV style="DISPLAY: inline; WIDTH: 152px; HEIGHT: 15px" ms_positioning="FlowLayout">GENERAL</DIV> </DIV> </TD> </TR> <TR> <TD style="WIDTH: 113px" align="right"> <DIV style="DISPLAY: inline; WIDTH: 105px; HEIGHT: 15px" ms_positioning="FlowLayout">Company Name</DIV> </TD> <TD style="WIDTH: 457px"> <asp:textbox id=txtName runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].name") %>' Width="414px"> </asp:textbox></TD> </TR> <TR> <TD style="WIDTH: 113px" align="right"> <DIV style="DISPLAY: inline; WIDTH: 105px; HEIGHT: 15px" ms_positioning="FlowLayout">Address Line 1</DIV> </TD> <TD style="WIDTH: 457px"> <asp:textbox id=txtAddress_line1 runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].address_line1") %>' Width="414px"> </asp:textbox></TD> </TR> <TR> <TD style="WIDTH: 113px" align="right"> <DIV style="DISPLAY: inline; WIDTH: 105px; HEIGHT: 15px" ms_positioning="FlowLayout">Address Line 2</DIV> </TD> <TD style="WIDTH: 457px"> <asp:textbox id=txtAddress_line2 runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].address_line2") %>' Width="414px"> </asp:textbox></TD> </TR> <TR> <TD style="WIDTH: 113px" align="right"> <DIV style="DISPLAY: inline; WIDTH: 105px; HEIGHT: 15px" ms_positioning="FlowLayout">City/State/Zip</DIV> </TD> <TD style="WIDTH: 457px"> <asp:textbox id=txtCity runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].city") %>' Width="156px"> </asp:textbox> <asp:textbox id=txtState runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].state") %>' Width="32px"> </asp:textbox> <asp:textbox id=txtZip runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].zip") %>' Width="95px"> </asp:textbox></TD> </TR> <TR> <TD style="WIDTH: 113px" align="right"> <DIV style="DISPLAY: inline; WIDTH: 105px; HEIGHT: 15px" ms_positioning="FlowLayout">Phone</DIV> </TD> <TD style="WIDTH: 457px"> <asp:textbox id=txtPhone1 runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].phone1") %>' Width="414px"> </asp:textbox></TD> </TR> <TR> <TD style="WIDTH: 113px" align="right"> <DIV style="DISPLAY: inline; WIDTH: 105px; HEIGHT: 15px" ms_positioning="FlowLayout">Fax</DIV> </TD> <TD style="WIDTH: 457px"> <asp:textbox id=txtFax runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].fax") %>' Width="414px"> </asp:textbox></TD> </TR> <TR> <TD style="WIDTH: 113px" align="right"></TD> <TD style="WIDTH: 457px"> <DIV align="center"> <DIV style="DISPLAY: inline; WIDTH: 146px; HEIGHT: 15px" ms_positioning="FlowLayout">FINANCIAL</DIV> </DIV> </TD> </TR> <TR> <TD style="WIDTH: 113px"> <DIV align="right"> <DIV style="DISPLAY: inline; WIDTH: 105px; HEIGHT: 15px" ms_positioning="FlowLayout">DUNS</DIV> </DIV> </TD> <TD style="WIDTH: 457px"> <asp:textbox id=txtDuns runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].duns") %>' Width="414px"> </asp:textbox></TD> </TR> <TR> <TD style="WIDTH: 113px" align="right"> <DIV style="DISPLAY: inline; WIDTH: 105px; HEIGHT: 15px" ms_positioning="FlowLayout">SIC No.</DIV> </TD> <TD style="WIDTH: 457px"> <asp:textbox id=txtSic_no runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].sic_no") %>' Width="414px"> </asp:textbox></TD> </TR> <TR> <TD style="WIDTH: 113px" align="right"> <DIV style="DISPLAY: inline; WIDTH: 105px; HEIGHT: 15px" ms_positioning="FlowLayout">Line of Business</DIV> </TD> <TD style="WIDTH: 457px"> <asp:textbox id=txtLine_of_business runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].line_of_business") %>' Width="414px"> </asp:textbox></TD> </TR> <TR> <TD style="WIDTH: 113px"> <DIV align="right"> <DIV style="DISPLAY: inline; WIDTH: 105px; HEIGHT: 15px" ms_positioning="FlowLayout">D & B Rating</DIV> </DIV> </TD> <TD style="WIDTH: 457px"> <asp:textbox id=txtDb_rating runat="server" CssClass="TextBox" Text='<%# DataBinder.Eval(dsCompanyInfo, "Tables[Company].DefaultView.[0].db_rating") %>' Width="414px"> </asp:textbox></TD> </TR> <TR> <TD style="WIDTH: 100%" align="center" colSpan="2"> <DIV align="center"> <DIV style="DISPLAY: inline; WIDTH: 134px; HEIGHT: 15px" ms_positioning="FlowLayout">CONTACT</DIV> </DIV> </TD> </TR> <TR> <TD style="WIDTH: 100%" align="center" colSpan="2"> <DIV align="center"> <asp ataGrid id=DataGrid1 runat="server" Width="100%"DataSource="<%# dsCompanyInfo %>" DataKeyField="contact_id" DataMember="Contact" ShowFooter="True" AutoGenerateColumns="False" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" GridLines="Vertical"> <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle> <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle> <ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle> <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"></HeaderStyle> <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle> <Columns> <asp:TemplateColumn> <FooterTemplate> <asp:LinkButton id="lbInsert" runat="server">Insert</asp:LinkButton> </FooterTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="First Name"> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemTemplate> <asp:Label id=lblFirstName runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.firstname") %>'> </asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox id="tbFirstName_New" runat="server" Width="75px" CssClass="TextBox"></asp:TextBox> </FooterTemplate> <EditItemTemplate> <asp:TextBox id=tbFirstName runat="server" Width="75px" Text='<%# DataBinder.Eval(Container, "DataItem.firstname") %>' CssClass="TextBox"> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Last Name"> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemTemplate> <asp:Label id=lblLastName runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.lastname") %>'> </asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox id="tbLastName_New" runat="server" Width="75px" CssClass="TextBox"></asp:TextBox> </FooterTemplate> <EditItemTemplate> <asp:TextBox id=tbLastName runat="server" Width="75px" Text='<%# DataBinder.Eval(Container, "DataItem.lastname") %>' CssClass="TextBox"> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Title"> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemTemplate> <asp:Label id=lblTitle runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.title") %>'> </asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox id="tbTitle_New" runat="server" Width="75px" CssClass="TextBox"></asp:TextBox> </FooterTemplate> <EditItemTemplate> <asp:TextBox id=tbTitle runat="server" Width="75px" Text='<%# DataBinder.Eval(Container, "DataItem.title") %>' CssClass="TextBox"> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Phone"> <HeaderStyle HorizontalAlign="Center"></HeaderStyle> <ItemTemplate> <asp:Label id=lblPhone runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.phone") %>'> </asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox id="tbPhone_New" runat="server" Width="75px" CssClass="TextBox"></asp:TextBox> </FooterTemplate> <EditItemTemplate> <asp:TextBox id=tbPhone runat="server" Width="75px" Text='<%# DataBinder.Eval(Container, "DataItem.phone") %>' CssClass="TextBox"> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn> <asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:ButtonColumn> </Columns> <PagerStyle HorizontalAlign="Center" ForeColor="Black" BackColor="#999999" Mode="NumericPages"></PagerStyle> </asp ataGrid></DIV></TD> </TR> <TR> <TD style="WIDTH: 134.8%; HEIGHT: 50px" align="center" colSpan="2" rowSpan="2"> <asp:button id="btnApply" runat="server" Text="Apply" ToolTip="Submit application to Provider"></asp:button> <asp:button id="btnSave" runat="server" Text="Save" ToolTip="Store application to complete later"></asp:button></TD> </TR> </TABLE> </gftp agebody></form></body> </HTML> ========================================================== "Bill Borg" <(E-Mail Removed)> wrote in message news:2C658DAD-ADE5-40DC-8F89-(E-Mail Removed)... > Can I see the code behind the UpdateCommand event for the grid, as well as the HTML (esp. the templates) behind the grid? Maybe I can spot something. > > ----- Mervin Williams wrote: ----- > > Yes, I do make those two calls. But, still the values are not refreshed. > > Mervin Williams > > ================================================ > "Bill Borg" <(E-Mail Removed)> wrote in message > news:0329C75A-6815-4CE9-830E-(E-Mail Removed)... > > After the update, are you refreshing the datagrid--i.e. myGrid.DataSource > = myDataSet and myGrid.DataBind()? > >> Bill Borg > > > |
|
||
|
||||
|
=?Utf-8?B?QmlsbCBCb3Jn?=
Guest
Posts: n/a
|
Two things
1. Maybe it's just my habit, but I'm pretty sure that you *always* need to repoint to the data source before the DataBind--i.e. it's not just a pointer but the values from the datasource are actually copied into the items collection of the grid control private void DataGrid1_CancelCommand(object source System.Web.UI.WebControls.DataGridCommandEventArgs e DataGrid1.EditItemIndex = -1 ** DataGrid1.DataSource = MyDataSource; * DataGrid1.DataBind() 2. As an aside, I've been writing similar code lately, and in the line that follows you should be able to replace e.item.cells(x).FindControl with just e.item.FindControl. Needless to say, this will save you tons of headache making sure you keep the ordinal values straight. Finding the controls on e.item presumes that a) these are top-level controls (not controls within, say, a user control, in which case you'd have to go find that user control first and then go finding some more down through its controls collection) and b) that whatever you're using for ID is unique across the entire row of the grid, which based on your example I presume it is (TextBox)(e.Item.Cells[1].FindControl("tbFirstName")) Bill |
|
||
|
||||
|
Mervin Williams
Guest
Posts: n/a
|
I tried both suggestions - and I'm still having the same problem.
Any other ideas? Mervin Williams "Bill Borg" <(E-Mail Removed)> wrote in message news:14C8AF5F-8404-4726-BD60-(E-Mail Removed)... > Two things: > > 1. Maybe it's just my habit, but I'm pretty sure that you *always* need to repoint to the data source before the DataBind--i.e. it's not just a pointer but the values from the datasource are actually copied into the items collection of the grid control. > > private void DataGrid1_CancelCommand(object source, > System.Web.UI.WebControls.DataGridCommandEventArgs e) > { > DataGrid1.EditItemIndex = -1; > ** DataGrid1.DataSource = MyDataSource; ** > DataGrid1.DataBind(); > } > > 2. As an aside, I've been writing similar code lately, and in the line that follows you should be able to replace e.item.cells(x).FindControl with just e.item.FindControl. Needless to say, this will save you tons of headache making sure you keep the ordinal values straight. Finding the controls on e.item presumes that a) these are top-level controls (not controls within, say, a user control, in which case you'd have to go find that user control first and then go finding some more down through its controls collection) and b) that whatever you're using for ID is unique across the entire row of the grid, which based on your example I presume it is. > > (TextBox)(e.Item.Cells[1].FindControl("tbFirstName")); > > Bill |
|
||
|
||||
|
=?Utf-8?B?QmlsbCBCb3Jn?=
Guest
Posts: n/a
|
Sorry I couldn't help, but am fresh out of ideas. At this point I'd copy to a testpage, strip out all but the very basics, get it to work simply, and build it back up. It's hard to jump into your code and spot something, but I know that the basic flow of using the canned Edit-Update-Cancel logic built into the grid works very well. Sorry.
|
|
||
|
||||
|
Marshal Antony
Guest
Posts: n/a
|
Hi Mervin,
The workaround is query the table after updation and bind it to the datagrid again in the same event handler. Hope this helps. Regards, Marshal Antony ..NET Developer http://www.dotnetmarshal.com "Mervin Williams" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)... > I have a datagrid with template columns. Upon editing the value of a column > in a row and clicking the update button, the original value is displayed. > However, the new (modified) value should be displayed. > > How do I get the new value to display after exiting out of update mode? > > Thanks in advance, > > Mervin Williams > > |
|
||
|
||||
|
dada
Guest
Posts: n/a
|
Marshal Antony,
Did you think of this?(it doesn`t help me ):private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here localhost.RasporedService s= new localhost.RasporedService(); dsDepartmani=s.WebPopuni("Osobe"); DataGrid1.DataSource=dsDepartmani; DataGrid1.DataMember="Osobe"; if(!IsPostBack) {DataGrid1.DataBind(); DataGrid1.PageIndexChanged += new DataGridPageChangedEventHandler(this.DataGrid1_Change); } } private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { localhost.RasporedService s= new localhost.RasporedService(); string ime, prez, tit; int Departman; string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString(); TextBox tb; tb=(TextBox)(e.Item.Cells[3].Controls[1]); ime = tb.Text; tb=(TextBox)(e.Item.Cells[4].Controls[1]); prez=tb.Text; DropDownList ddl; ddl=(DropDownList)(e.Item.Cells[5].Controls[1]); tit=ddl.SelectedItem.Text; ddl=(DropDownList)(e.Item.Cells[7].Controls[1]); Departman=Convert.ToInt32(ddl.SelectedItem.Value); DsDepartmani.OsobeRow rd; rd=dsDepartmani.Osobe.FindByID_osobe(int.Parse(key)); if (rd!=null) { rd.Ime=ime; rd.Prezime=prez; rd.Titula=tit; rd.ID_departmana=Convert.ToInt32(Departman); s.WebSnimi(dsDepartmani); dsDepartmani.AcceptChanges(); } DataGrid1.EditItemIndex = -1; DataGrid1.DataBind(); } |
|
||
|
||||
|
|
|
| |
![]() |
| Thread Tools | |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DataGrid UpdateCommand | Leona Smyth | Microsoft C# .NET | 0 | 9th Jul 2004 09:57 AM |
| DataGrid UpdateCommand refresh problem | Mervin Williams | Microsoft ADO .NET | 2 | 17th Mar 2004 11:23 AM |
| Problem refreshing values in DataGrid UpdateCommand | Mervin Williams | Microsoft ADO .NET | 3 | 15th Mar 2004 03:12 PM |
| Problem refreshing values in DataGrid UpdateCommand | Mervin Williams | Microsoft ASP .NET | 0 | 14th Mar 2004 03:43 PM |
| update problem in DataGrid's UpdateCommand method | dawn | Microsoft ASP .NET | 1 | 28th Jul 2003 03:49 PM |
Powered by vBulletin®. Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2010, Crawlability, Inc. |





