I have a column defined as:
This column is the only edit-able field in the grid, the rest are bound columns marked as ReadOnly. The grid always has all rows in edit mode using the following:
I have a button which needs to look at each row's check box and remove any items that are checked (perfromed by the CleanUpData method). The button's click handler is:
Here is the UpdateCommand event from the grid's code:
Here, the line that uses '
This method shouldn't matter but I'm including it for completeness' sake (this code would only have an impact if at least 1 checkbox is detected as checked):
I've searched the forums, read the help articles, looked at the demos, but cannot figure out what is wrong. Any ideas?
<
telerik:GridCheckBoxColumn
ConvertEmptyStringToNull
=
"False"
FilterControlAltText
=
"Filter checked column"
SortExpression
=
"Checked"
UniqueName
=
"Checked"
DataField
=
"Checked"
HeaderText
=
"Remove"
ToolTip
=
"Check this box to remove this item from your cart"
DataType
=
"System.Boolean"
>
<
HeaderStyle
Wrap
=
"False"
HorizontalAlign
=
"Left"
Width
=
"80px"
CssClass
=
"grid-header grid-header-first"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
Width
=
"100%"
VerticalAlign
=
"Top"
/>
</
telerik:GridCheckBoxColumn
>
This column is the only edit-able field in the grid, the rest are bound columns marked as ReadOnly. The grid always has all rows in edit mode using the following:
protected
void
grdItems_PreRender(
object
sender, EventArgs e)
{
try
{
foreach
(GridDataItem colGridField
in
grdItems.MasterTableView.Items)
colGridField.Edit =
true
;
grdItems.Rebind();
}
catch
(Exception ex)
{
System.Diagnostics.Debug.Print(
"Error: "
+ ex.ToString());
Exceptions.ProcessModuleLoadException(
this
, ex);
}
}
I have a button which needs to look at each row's check box and remove any items that are checked (perfromed by the CleanUpData method). The button's click handler is:
protected
void
btnUpdateCart_Click(
object
sender, EventArgs e)
{
try
{
//grdItems.MasterTableView.Items[grdItems.MasterTableView.Items.Count - 1].FireCommandEvent("UpdateAll", string.Empty);
grdItems.EditItems[0].FireCommandEvent(
"UpdateEdited"
,
string
.Empty);
}
catch
(Exception ex)
{
System.Diagnostics.Debug.Print(
"Error: "
+ ex.ToString());
Exceptions.ProcessModuleLoadException(
this
, ex);
}
}
Here is the UpdateCommand event from the grid's code:
protected
void
grdItems_UpdateCommand(
object
sender, Telerik.Web.UI.GridCommandEventArgs e)
{
GridEditableItem itmUpdatedRow =
null
;
Hashtable tblUpdatedValues =
null
;
try
{
//Get the details of the item that needs to be updated
itmUpdatedRow = e.Item
as
GridEditableItem;
tblUpdatedValues =
new
Hashtable();
//Parse out the updated data
e.Item.OwnerTableView.ExtractValuesFromItem(tblUpdatedValues, itmUpdatedRow);
//Update the underlying data table with the updated information (THIS IS ALWAYS FALSE REGARDLESS OF CHECKED STATUS)
_propsSettings.Records.Rows[e.Item.DataSetIndex][
"Checked"
] = tblUpdatedValues[
"Checked"
].ToString().GetBoolean();
grdItems.Rebind();
CleanUpData();
}
catch
(Exception ex)
{
System.Diagnostics.Debug.Print(
"Error: "
+ ex.ToString());
Exceptions.ProcessModuleLoadException(
this
, ex);
}
finally
{
SaveControlState();
//Clean up
if
(tblUpdatedValues !=
null
)
{
tblUpdatedValues.Clear();
tblUpdatedValues =
null
;
}
}
}
Here, the line that uses '
tblUpdatedValues[
"Checked"
]
' is ALWAYS False regardless of the check boxes status. I had a similar issue before using a dropdown column but I got around that by changing it's editor to a standard ASP.NET dropdown. I tried doing the same here but I got the same results. The value of the Checked column is ALWAYS False no matter what I do.This method shouldn't matter but I'm including it for completeness' sake (this code would only have an impact if at least 1 checkbox is detected as checked):
/// <summary>
/// Cleans up the Items grid data to make sure any invalid rows are removed.
/// </summary>
private
void
CleanUpData()
{
try
{
_propsSettings.TotalPrice = 0;
_propsSettings.ShippingTotal = 0;
_propsSettings.LateFees = 0;
if
(_propsSettings.Records.Rows.Count > 0)
{
//Start at the end so that removing rows won't cause the index to be incorrect
for
(
int
iItems = (_propsSettings.Records.Rows.Count - 1); iItems > -1; iItems--)
{
try
{
//Item was selected for removal
if
(_propsSettings.Records.Rows[iItems][0].ToString().GetBoolean())
{
//Delete the line item database record and remove it from the data set
}
else
{
//Track the calculated totals
_propsSettings.ShippingTotal += _propsSettings.Records.Rows[iItems][
"ShippingPrice"
].ToString().GetNumber();
_propsSettings.TotalPrice += ((_propsSettings.Records.Rows[iItems][
"OriginalPrice"
].ToString().GetNumber() * _propsSettings.Records.Rows[iItems][
"Quantity"
].ToString().GetNumber()) + _propsSettings.Records.Rows[iItems][
"ShippingPrice"
].ToString().GetNumber());
}
}
catch
(Exception ex)
{
System.Diagnostics.Debug.Print(
"Error: "
+ ex.ToString());
}
}
}
}
catch
(Exception ex)
{
System.Diagnostics.Debug.Print(
"Error: "
+ ex.ToString());
Exceptions.ProcessModuleLoadException(
this
, ex);
}
finally
{
SaveControlState();
UpdateCartTotals();
grdItems.Rebind();
}
}
I've searched the forums, read the help articles, looked at the demos, but cannot figure out what is wrong. Any ideas?