Community,
I have a RadGrid that I define my columns. Most of them are visible and read only; however, a few are updated. I also have a few columns that are not visible. I use these in my SQL update as my primary key. When you enter the RadGrid I automatically enable edit in every row of the entire grid for the editable columns. When a user is done doing a bulk update, they click my Update All button and the following code is ran:
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == "EditAll")
{
foreach (GridItem item in RadGrid1.MasterTableView.Items)
{
if (item is GridEditableItem)
{
GridEditableItem editableItem = item as GridDataItem;
editableItem.Edit = true;
}
}
}
if (e.CommandName == "UpdateAll")
{
//-- foreach (GridEditableItem editedItem in RadGrid1.EditItems)
foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)
{
Hashtable newValues = new Hashtable();
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, dataItem);
SqlDataSource1.UpdateCommand = String.Format("UPDATE MY_TABLE SET AOScan_Num='{0}', PLANNED_REMEDIATION_STATUS_ID='{1}', " +
"ServiceNow_Num='{2}', TICKET_CREATION_DATE='{3}' WHERE QID='{4}' AND IP='{5}' AND PORT='{6}'",
newValues["AOScan_Num"],
newValues["PLANNED_REMEDIATION_STATUS_ID"],
newValues["ServiceNow_Num"],
newValues["TICKET_CREATION_DATE"],
dataItem["QID"].Text,
dataItem["IP"].Text,
Convert.ToInt32(dataItem["PORT"].Text));
SqlDataSource1.Update();
dataItem.Edit = false;
}
}
RadGrid1.Rebind();
}
The problem I am running into is, when my code executes the SQL it returns the correct values from RadGrid for each row; however, the fields that are not visible and not editable are empty instead of holding the correct value. I was hoping someone has an idea of what might be going on.
Kind Regards,
Ben
I have a RadGrid that I define my columns. Most of them are visible and read only; however, a few are updated. I also have a few columns that are not visible. I use these in my SQL update as my primary key. When you enter the RadGrid I automatically enable edit in every row of the entire grid for the editable columns. When a user is done doing a bulk update, they click my Update All button and the following code is ran:
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == "EditAll")
{
foreach (GridItem item in RadGrid1.MasterTableView.Items)
{
if (item is GridEditableItem)
{
GridEditableItem editableItem = item as GridDataItem;
editableItem.Edit = true;
}
}
}
if (e.CommandName == "UpdateAll")
{
//-- foreach (GridEditableItem editedItem in RadGrid1.EditItems)
foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)
{
Hashtable newValues = new Hashtable();
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, dataItem);
SqlDataSource1.UpdateCommand = String.Format("UPDATE MY_TABLE SET AOScan_Num='{0}', PLANNED_REMEDIATION_STATUS_ID='{1}', " +
"ServiceNow_Num='{2}', TICKET_CREATION_DATE='{3}' WHERE QID='{4}' AND IP='{5}' AND PORT='{6}'",
newValues["AOScan_Num"],
newValues["PLANNED_REMEDIATION_STATUS_ID"],
newValues["ServiceNow_Num"],
newValues["TICKET_CREATION_DATE"],
dataItem["QID"].Text,
dataItem["IP"].Text,
Convert.ToInt32(dataItem["PORT"].Text));
SqlDataSource1.Update();
dataItem.Edit = false;
}
}
RadGrid1.Rebind();
}
The problem I am running into is, when my code executes the SQL it returns the correct values from RadGrid for each row; however, the fields that are not visible and not editable are empty instead of holding the correct value. I was hoping someone has an idea of what might be going on.
Kind Regards,
Ben