General information
Title:
DataGrid and Update SP in C# with ASP
We have a DataGrid with a update SP in SQL server 2000. The DataGrid_Update fires because we watch it in the profiler. The data from the Grid doesn't make it into the parameters.Does anyone have any ideas on how the data is sent from the client back to the server. The form has a method=post on the form.
Thanks in advance
Bruce Carpenter
See code below...
public void DataGrid1_Update(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (IsPostBack)
{
String[] cols = {"@SLD_Results_PK","@SLD_Last_Name","@SLD_First_Name","@SLD_Mid_Name","@SLD_DOB","@SLD_Gender","@SLD_Race","@SLD_Ethnicity","@SLD_Address","@SLD_City","@SLD_State","@SLD_Zip","@SLD_County","@SLD_Encounter_Date","@SLD_Cosite","@SLD_Test_Date","@SLD_Test_Type","@SLD_Result","@SLD_Result_Date","@SLD_Lab_Name","@SLD_Process_Flag"};
int numCols = e.Item.Cells.Count;
string emailstr = "";
for (int i=1; i {
String colvalue =((TextBox)e.Item.Cells[i].Controls[0]).Text;
sqlUpdateCommand1.Parameters[cols[i-1]].Value = Server.HtmlEncode(colvalue);
emailstr += (colvalue + ",");
}
//Email(emailstr);
if (sqlConnection1.State!=System.Data.ConnectionState.Open)
{
sqlConnection1.Open();
}
try
{
sqlUpdateCommand1.ExecuteNonQuery();
DataGrid1.EditItemIndex = -1;
//sqlDataAdapter1.Fill(sldResults1);
//DataGrid1.DataSource=sldResults1;
DataGrid1_Bind();
}
catch (SqlException exc)
{
if (exc.Number == 2627)
Email("ERROR: A record already exists with the same primary key");
else
Email("ERROR: Could not update record, please ensure the fields are correctly filled out");
}
}
}
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only