I am attempting to implement batch updating using controls that are located within the EditItemTemplate of a GridTemplate Column. I am currently using a OnPreRender event to set all datagrid columns to edit mode. The idea is the user should then be able to select values in a radcombobox and check box located in a GridTemplate column for each entry in the grid. After the users has made their edits to multiple rows in the grid they should be able to hit a single button to process all updates. I am attempting to use an approach similar to what is described in this article however I have been having difficulties with my OnItemCommand event as I have been unable to retrieve the values the radcombo box and check box in my EditItemTemplate have been set to.
Below is what I am attempting to do currently. Also I would like to remove the "update" and "cancel" links from the EditItemTemplate rather then set the text of the link to nothing in a OnItemCreated event as I am doing currently. Thanks in advance for helping out a Telerik beginner.
<
telerik:RadGrid ID="gridTestGrid" runat="server" AllowMultiRowEdit="True"
OnNeedDataSource
="gridTestGrid_DataSource"
OnItemDataBound
="gridTestGrid_ItemDataBound" OnPreRender="gridTestGrid_PreRender" OnItemCreated="gridTestGrid_ItemCreated" OnItemCommand="gridTestGrid_ItemCommand"
AutoGenerateColumns
="False" GridLines="Horizontal">
<
MasterTableView AutoGenerateColumns="False" CommandItemDisplay="TopAndBottom" DataKeyNames="TestGridID">
<
CommandItemTemplate>
<
asp:Button ID="btnUpdate" runat="server" Text="Update Changes" />
</
CommandItemTemplate>
<
RowIndicatorColumn>
<
HeaderStyle Width="20px"></HeaderStyle>
</
RowIndicatorColumn>
<
ExpandCollapseColumn>
<
HeaderStyle Width="20px"></HeaderStyle>
</
ExpandCollapseColumn>
<
Columns>
......Some Other Columns .....
<
telerik:GridTemplateColumn HeaderText="Facility" Visible="false"
UniqueName
="rcbColumn">
<
ItemTemplate>
</
ItemTemplate>
<
EditItemTemplate>
<
telerik:RadComboBox ID="rcbFacility" runat="server" AllowCustomText="true" MarkFirstMatch="true" Width="300px" AppendDataBoundItems="true"></telerik:RadComboBox>     Send to IT?: <asp:CheckBox ID="ckBox" runat="server" Checked="false" />
</
EditItemTemplate>
</
telerik:GridTemplateColumn>
</
Columns>
</
MasterTableView>
protected
void gridTestGrid_ItemCreated(object source, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item is GridEditableItem && e.Item.IsInEditMode)
{
LinkButton
updateButton = (LinkButton)e.Item.FindControl("UpdateButton");
updateButton.Text =
"";
LinkButton
cancelButton = (LinkButton)e.Item.FindControl("CancelButton");
cancelButton.Text =
"";
}
}
protected
void gridTestGrid_PreRender(object source, EventArgs e)
{
foreach
(GridDataItem item in gridTestGrid.Items)
{
item.Edit =
true;
gridTestGrid.Rebind();
}
}
protected
void gridTestGrid_ItemCommand(object source, GridCommandEventArgs e)
{
Hashtable
newValues = new Hashtable();
foreach
(GridEditableItem editedItem in gridTestGrid.Items)
{
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
RadComboBox
combo = ((RadComboBox)editedItem["rcbColumn"].FindControl("rcbFacility"));
if
(combo != null)
{
string
selected = combo.SelectedItem.ToString();
}
}
}