I have radgrid, with 3 command buttons(Edit, Save and Cancel)
On Edit click Save and cancel buttons should be visible. (By default they should be disabled)
after Save or Cancel click grid goes to read only mode and only Edit command button should be displayed.
i tried all the possibilities by finding the command button and disabling it. Though there is no exception or anything still couldn't achieve this functionality.
Please help me out..it is needed immediately.
CODE :
<telerik:RadGrid ID="gridMilitaryPension" runat="server" AutoGenerateColumns="false" AllowMultiRowEdit="true" RenderMode="lightweight"
Skin="Office2007" PagerStyle-Mode="NextPrevAndNumeric" AllowPaging="True" PageSize="30" OnNeedDataSource="gridMilitaryPension_NeedDataSource"
OnItemCommand="gridMilitaryPension_ItemCommand" >
<MasterTableView CommandItemDisplay="Top" EditMode="InPlace" Font-Size="10pt">
<Columns>
<telerik:GridBoundColumn UniqueName="ID" DataField="ID" HeaderText="ID" Display="true" ReadOnly="True"
ForceExtractValue="Always">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="slottype" DataField="slottype" HeaderText="Slot Type" SortExpression="slottype" ReadOnly="True"
ForceExtractValue="Always">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="total" UniqueName="total" HeaderText="Total Seats" SortExpression="total">
<ItemTemplate>
<asp:Label ID="lblTotalSeats" runat="server" Text='<%# Eval("total") %>' class="classLblTotal"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtTotalSeats" runat="server" Text='<%# Eval("total") %>' Width="100%" class='<%# Eval("slottype") %>' onblur="addition(this)" onchange="DataChanged(this)"></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<CommandItemTemplate>
<table>
<tr>
<td> <asp:Button runat="server" ID="btnSaveAllChanges" Text="Save All Changes" CommandName="SaveAllChanges" /></td>
<td> <asp:Button runat="server" ID="btnCancel" Text="Cancel" CommandName="Cancel" /></td>
<td> <asp:Button runat="server" ID="btnEdit" Text="Edit Total Seats" CommandName="Edit" onclick="btnEdit_Click"/></td>
</tr>
</table>
</CommandItemTemplate>
</MasterTableView>
</telerik:RadGrid>
In code Behind:
protected void gridMilitaryPension_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
//Below i am capturing the controls and trying to hide/unhide. used visible property also but no luck
GridCommandItem cmditem = (GridCommandItem)e.Item;
Button btnSaveAllChanges = cmditem.FindControl("btnSaveAllChanges") as Button;
Button btnCancel = cmditem.FindControl("btnCancel") as Button;
Button btnEdit = cmditem.FindControl("btnEdit") as Button;
btnSaveAllChanges.Enabled = true;
btnCancel.Enabled = true;
btnEdit.Enabled = false;
}
}
if (e.CommandName == "SaveAllChanges")
{
//after logic, Edit button should be enabled.
}
return;
}
if (e.CommandName == "Cancel")
{
gridMilitaryPension.MasterTableView.ClearEditItems();
gridMilitaryPension.Rebind();
}
}