Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
RowUpdating Event not firing.
posted

Hi,

I'm trying to develop an auditing system to keep track of all our stock. I'd like to be able to edit data but the RowUpdating event is not firing after data is changed. I use a dynamic data source and have included some of the code.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

SqlDataSource3.ConnectionString =

 

ConfigurationManager.ConnectionStrings["AuditConnectionString"

].ConnectionString;

 

 

if (_SubType != null

)

{

SqlDataSource3.SelectCommand =

 

"SELECT vw_" + _Type + ".* FROM vw_" + _Type + " WHERE [SubType] = '" + _SubType + "'"

;

}

 

 

else

{

SqlDataSource3.SelectCommand =

"SELECT vw_" + _Type + ".* FROM vw_" + _Type + ""

;

}

WebDataGrid1.DataSource = SqlDataSource3;

 

 

 

if (_Type == "Computers")

 

 

this.WebDataGrid1.DataKeyFields = "ComputerID";

 

 

if (_Type == "Audio")

 

 

this.WebDataGrid1.DataKeyFields = "AudioID"

;

 

 

if (_Type == "Cables")

WebDataGrid1.DataKeyFields =

"CableID"

;

 

 

if (_Type == "HardDrive")

WebDataGrid1.DataKeyFields =

"HardDriveID"

;

 

 

if (_Type == "KeyboardMouse")

WebDataGrid1.DataKeyFields =

"KeyboardMouseID"

;

 

 

if (_Type == "Miscellaneous")

WebDataGrid1.DataKeyFields =

"MiscID"

;

 

 

if (_Type == "Memory")

WebDataGrid1.DataKeyFields =

"MemoryID"

;

 

 

if (_Type == "HardDrive")

WebDataGrid1.DataKeyFields =

"HardDriveID"

;

 

 

if (_Type == "NetworkEquipment")

WebDataGrid1.DataKeyFields =

"NetworkID"

;

 

 

if (_Type == "PhoneEquipment")

WebDataGrid1.DataKeyFields =

"PhoneID"

;

 

 

if (_Type == "VideoCard")

WebDataGrid1.DataKeyFields =

"VideoCardID"

;

 

this.WebDataGrid1.Behaviors.CreateBehavior<EditingCore>();

 

this.WebDataGrid1.Behaviors.EditingCore.Behaviors.CreateBehavior<RowEditingTemplate>();

 

this.WebDataGrid1.Behaviors.EditingCore.Behaviors.RowEditTemplate.EditModeActions.MouseClick = EditMouseClickAction.Double;

 

this.WebDataGrid1.Behaviors.EditingCore.Behaviors.RowEditTemplate.OKButton = "OkButton";

 

this.WebDataGrid1.Behaviors.EditingCore.Behaviors.RowEditTemplate.CancelButton = "CancelButton";

 

if (_Type == "Computers")

{

 

this.WebDataGrid1.Behaviors.EditingCore.Behaviors.RowEditTemplate.Template = new ComputerCustomRowEditingTemplate();

daColumns =

new SqlDataAdapter("SELECT column_name FROM information_schema.columns WHERE table_name = 'vw_Computers'", sqlConnection);

dsColumnNames =

new DataSet();

sqlConnection.Open();

daColumns.Fill(dsColumnNames,

"Columns");

sqlConnection.Close();

 

RowEditingClientBinding item = new RowEditingClientBinding();

 

foreach (DataRow row in dsColumnNames.Tables["Columns"].Rows)

{

item =

new RowEditingClientBinding();

item.ColumnKey = row[

"column_name"].ToString();

item.ControlID =

"WebDataGrid1_ctl00_txt" + row["column_name"].ToString();

item.GetValueJavaScript =

"$get('WebDataGrid1_ctl00_txt" + row["column_name"].ToString() + "').value";

item.SetValueJavaScript =

"$get('WebDataGrid1_ctl00_txt" + row["column_name"].ToString() + "').value={value};";

 

this.WebDataGrid1.Behaviors.EditingCore.Behaviors.RowEditTemplate.ClientBindings.Add(item);

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

protected void WebDataGrid1_RowUpdating(object sender, Infragistics.Web.UI.GridControls.RowUpdatingEventArgs e)

{

 

 

int ID = int.Parse(e.Values["ComputerID"].ToString());

 

 

string MachineName = e.Values["Machine Name"].ToString();

 

 

string SerialNumber = e.Values["Serial Number"].ToString();

 

 

string CPU = e.Values["CPU"].ToString();

 

 

string RAM = e.Values["RAM"].ToString();

 

 

string HDD = e.Values["HDD"].ToString();

 

 

string Optical = e.Values["Optical"].ToString();

 

 

string ComputerLoc = e.Values["Computer Location"].ToString();

 

 

string PurDate = e.Values["Computer Purchased Date"].ToString();

 

 

string PurPrice = e.Values["Est. Computer Purchase Price"].ToString();

 

 

string Disposed = e.Values["Computer Disposed"].ToString();

SqlDataSource3.UpdateCommand =

"Update [vw_Computers] SET [Machine Name] = '" + MachineName + "' WHERE [ComputerID] = " + ID;

And my asp code

<

 

ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="32%" Width="100%" DataKeyFields="ComputerID" OnRowUpdating="WebDataGrid1_RowUpdating">

 

<Behaviors>

 

<ig:Paging PageSize="50" PagerAppearance="Bottom" Enabled="true" />

 

<ig:Selection CellClickAction="Row" RowSelectType="Single">

 

</ig:Selection>

 

<ig:EditingCore>

 

<Behaviors>

 

<ig:RowEditingTemplate>

 

<EditModeActions MouseClick="Double" RowSelectorMouseClick="None" />

 

</ig:RowEditingTemplate>

 

</Behaviors>

 

</ig:EditingCore>

 

<ig:RowSelectors>

 

</ig:RowSelectors>

 

<ig:Activation>

 

</ig:Activation>

 

</Behaviors>

 

</ig:WebDataGrid>

Nothing is getting updated and if I put a break point in the function it is not even being called. Any help would be much appreciated

Parents
No Data
Reply Children