When I click on the Edit button, I simply want to enable/disable some fields.
No matter what I try in the below code-behind, I'm getting a null value from the "editedItem", which then means the rest of the items using the FindControl will also be null.
Can someone please inform me how I can get a reference to the edited item (editedItem)?
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
if (e.Item is GridDataItem)
{
GridEditableItem editedItem = (source as RadGrid).NamingContainer as GridEditableItem;
//GridEditableItem editedItem = e.Item as GridEditableItem;
DropDownList FileTypeID = editedItem.FindControl("FileTypeID") as DropDownList;
TextBox StartPosition = editedItem.FindControl("StartPosition") as TextBox;
TextBox EndPosition = editedItem.FindControl("EndPosition") as TextBox;
TextBox Delimiter = editedItem.FindControl("Delimiter") as TextBox;
CheckBox IsMultiRecordType = editedItem.FindControl("IsMultiRecordType") as CheckBox;
TextBox FirstRecordIndicator = editedItem.FindControl("FirstRecordIndicator") as TextBox;
TextBox RecordIndicatorIndex = editedItem.FindControl("RecordIndicatorIndex") as TextBox;
if (IsMultiRecordType.Checked == true)
FirstRecordIndicator.Enabled = true;
else
{
FirstRecordIndicator.Text = null;
FirstRecordIndicator.Enabled = false;
}
switch (FileTypeID.SelectedItem.Text)
{
case "Space Fixed Length":
StartPosition.Enabled = true;
EndPosition.Enabled = true;
Delimiter.Text = null;
Delimiter.Enabled = false;
RecordIndicatorIndex.Text = null;
RecordIndicatorIndex.Enabled = false;
break;
case "Delimited File":
StartPosition.Text = null;
StartPosition.Enabled = false;
EndPosition.Text = null;
EndPosition.Enabled = false;
Delimiter.Enabled = true;
RecordIndicatorIndex.Enabled = true;
break;
case "HL7":
StartPosition.Text = null;
StartPosition.Enabled = false;
EndPosition.Text = null;
EndPosition.Enabled = false;
Delimiter.Enabled = true;
RecordIndicatorIndex.Enabled = true;
break;
}
}
}
}