
bharat kumar
Top achievements
Rank 1
bharat kumar
asked on 18 Sep 2010, 06:59 PM
Hi,
i am using terelik radgrid and i want to disable delete button on some condition. but i could not able to find out the button ...
here is the grid code...
please help me as i could not able to find the button in code...
thanks.
i am using terelik radgrid and i want to disable delete button on some condition. but i could not able to find out the button ...
here is the grid code...
<telerik:RadPageView ID="rpvActions" runat="server">
<div>
<table style="width: 780px; height: 256px;">
<tr>
<td colspan="2" valign="top" style="height: 100px">
<asp:Panel ID="pnlActions" runat="server" GroupingText="Workplan"
CssClass="groupBoxActionGrid" Style="position: relative; z-index: 100; top: 0px; left: 0px; "
Font-Size="12px" Width="780px">
<div style="left: 0px; width: 100%; position: relative; top: 0px;">
<telerik:RadGrid runat="server"
ID="grdActions"
AllowPaging="false"
Width="750px"
AutoGenerateColumns="false"
Skin="Office2007"
DataSourceID="TaskActionsDataSource"
AllowAutomaticInserts="true"
AllowAutomaticUpdates="true"
AllowAutomaticDeletes="true"
CommandItemDisplay="Top"
OnItemDataBound="grdActions_ItemDataBound"
>
<ClientSettings EnableAlternatingItems="true"
EnableRowHoverStyle="true"
AllowExpandCollapse="false"
ClientEvents-OnPopUpShowing="PopUpShowing"
>
<DataBinding EnableCaching="true" />
<Selecting AllowRowSelect="True" />
</ClientSettings>
<MasterTableView DataKeyNames="Id" TableLayout="Fixed"
AllowMultiColumnSorting="false"
AllowFilteringByColumn="false"
AlternatingItemStyle-BackColor="#F2F3F5"
AllowAutomaticInserts="true"
AllowAutomaticUpdates="true"
CommandItemDisplay="Top"
NoMasterRecordsText="There are currently no actions for the task. Note that at least one action needs to be present"
EditMode="PopUp"
>
<Columns>
<telerik:GridBoundColumn
DataField="SortCode"
Visible="true"
HeaderText="#"
HeaderStyle-Width = "30"
ItemStyle-Font-Bold="true"
ItemStyle-Font-Names="Tahoma"
>
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="TemplateColumn" InitializeTemplatesFirst="false">
<HeaderTemplate>
<table id="Table1" cellspacing="0" cellpadding="0" border="0">
<tr>
<td colspan="0">
<b>Action Details</b>
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="border-width: 0px;"><input type="hidden" id="hiddenActionId" value="<%# Eval("Id") %>" /></td>
</tr>
<tr>
<td colspan="6" style="width: 200px; font-size: 12px; font-family: Tahoma;">
<b>Name: </b><%# Eval("Description") %> (<%# Eval("TypeName") %>) <%# Convert.ToBoolean(Eval("Location").Equals("")) ? "" : ":: " + Eval("Location")%>
</td>
<td align="right">
<img src="../images/status_<%# Eval("StatusName")%>.png" alt="<%# Eval("StatusName")%>" />
</td>
</tr>
<tr>
<td colspan="4" style="width: 250px; font-size: 12px; font-family: Tahoma;">
<b>Output: </b> <%# Eval("Output") %>
</td>
<td rowspan="3" style="width: 50px; font-size: 12px; font-family: Tahoma;" align="center">
<img src="../images/status_<%# Convert.ToBoolean(Eval("NoBudgetFlag")) ? "nobudget" : "budget" %>.png"
alt='<%# Convert.ToBoolean(Eval("NoBudgetFlag")) ? "No budget required for this action" : "Budget estimation required for this action" %>' />
</td>
<td colspan="2" rowspan="3" style="width: auto; font-size: 12px; font-family: Tahoma;" align="center">
$ <%# Eval("TotalEstimationInDollar") %> € <%# Eval("TotalEstimationInEuro") %>
</tr>
<tr>
<td colspan="4" style="font-size: 12px; font-family: Tahoma;">
<b>Date: </b> <%# Eval("StartDate") %> <%# Convert.ToBoolean(Eval("CompletionDate").Equals("")) ? "" : " to " + Eval("CompletionDate") %>
</td>
</tr>
<tr>
<td colspan="4" style="font-size: 12px; font-family: Tahoma;">
<b>Comment: </b> <%# Eval("Comment") %>
</td>
</tr>
</table>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridButtonColumn
ConfirmTitle="Edit" ButtonType="ImageButton" ImageUrl="~/Images/Edit.gif" CommandName="Edit" Text="Edit"
UniqueName="EditCommandColumn" HeaderStyle-Width="30px">
<ItemStyle HorizontalAlign="Center" />
</telerik:GridButtonColumn>
<telerik:GridButtonColumn ConfirmText="Are you sure you want to delete the action (NOTE: Task save is required to persist the operation)?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete Record" ButtonType="ImageButton" ImageUrl="~/Images/Delete.gif" CommandName="Delete" Text="Delete"
UniqueName="DeleteCommandColumn" HeaderStyle-Width="30px">
<ItemStyle HorizontalAlign="Center" />
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings EditFormType="Template" PopUpSettings-Width="620px"
PopUpSettings-Height="390px" CaptionFormatString="Action Details">
<FormTemplate>
<table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
style="border-collapse: collapse; background: white; height: 320px; width: 600px;">
<asp:Label runat="server" ID="actionId" value='<%# Eval("Id") %>' />
<br />
<tr>
<td>
<table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0">
<tr>
<td class="smallFont" style="top: 82px; position: absolute;">Name </td>
<td class="smallFont" style="top: 79px; position: absolute; left: 65px;">
<asp:TextBox ID="txtDescription" runat="server" Text='<%# Bind("Description") %>' Width="500px">
</asp:TextBox>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator5" ControlToValidate="txtDescription"
ErrorMessage="* Enter Name" Style="z-index: 106; left: 670px;
position: absolute; top: 51px" Display="None" ValidationGroup="actionsave"/>
</td>
</tr>
<tr>
<td class="smallFont" style="top: 112px; position: absolute;">Type </td>
<td style="top: 109px; left: 65px; position: absolute;">
<asp:RadioButtonList ID="rblActionType" runat="server" Height="26px" ReadOnly="true" Width="220px" AppendDataBoundItems="true" RepeatDirection="Horizontal"
AutoPostBack="false" SelectedValue='<%# Bind("ActionTypeId") %>' DataSourceID="ActionTypeInfoList"
DataValueField="Id" DataTextField="Name" OnTextChanged="rblActionType_TextChanged"
>
<asp:ListItem Value="" Text="" style="display: none;" />
</asp:RadioButtonList>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="rblActionType"
ErrorMessage="* Select Action Type" Style="z-index: 106; left: 670px;
position: absolute; top: 51px" Display="None" ValidationGroup="actionsave"/>
</td>
</tr>
<tr>
<td class="smallFont" style="top: 138px; position: absolute;">
Location </td>
<td>
<asp:TextBox ID="txtLocation" runat="server" Text='<%# Bind("Location") %>' Width="500px" style="top: 136px; left: 65px; position: absolute;">
</asp:TextBox></td>
</tr>
<tr>
<td class="smallFont" style="top: 165px; position: absolute;">Start </td>
<td class="smallFont">
<telerik:RadDatePicker ID="startDate" runat="server" Skin="Web20" DbSelectedDate='<%# Bind("StartDate") %>' style="top: 164px; left: 65px; position: absolute;">
</telerik:RadDatePicker>
<asp:Label ID="Label1" runat="server" style="top: 165px; position: absolute; left: 250px;" Text="End Date" />
<telerik:RadDatePicker ID="endDate" runat="server" Skin="Web20" DbSelectedDate='<%# Bind("CompletionDate") %>' style="top: 164px; position: absolute; left: 315px;">
</telerik:RadDatePicker>
</td>
</tr>
<tr>
<td class="smallFont" style="top: 195px; position: absolute;">Status </td>
<td>
<asp:DropDownList runat="server" DataSourceID="ActionStatusInfoList" AppendDataBoundItems="true"
ID="cboActionStatus" Width="220px" DataValueField="Id"
DataTextField="Name" SelectedValue='<%# Bind("ActionStatusId") %>' style="height: 21px; top: 192px; left: 65px; position: absolute;"
OnTextChanged="cboActionStatus_TextChanged"
>
<asp:ListItem Value="" Text=""></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator4" ControlToValidate="cboActionStatus"
ErrorMessage="* Select Status" Style="z-index: 106; left: 670px;
position: absolute; top: 51px" Display="None" ValidationGroup="actionsave"/>
</td>
</tr>
<tr>
<td class="smallFont" style="top: 221px; position: absolute;">
Output </td>
<td>
<asp:TextBox ID="txtOutput" runat="server" Text='<%# Bind("Output") %>' Width="500px" style="top: 223px; left: 65px; position: absolute;">
</asp:TextBox></td>
</tr>
<tr>
<td class="smallFont" style="top: 253px; position: absolute;">Requires Budget?</td>
<td style="top: 0px; left: 105px; position: absolute;">
<asp:RadioButtonList ID="RadioButtonList2" runat="server" Height="26px"
ReadOnly="true" Width="220px" RepeatDirection="Horizontal" style="top: 251px; position: absolute;"
AutoPostBack="false" SelectedValue='<%# Bind("NoBudgetFlag") %>'
>
<asp:ListItem Value="" Text="" style="display: none;" />
<asp:ListItem Value="False" Text="Yes" />
<asp:ListItem Value="True" Text="No" />
</asp:RadioButtonList>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="RadioButtonList2"
ErrorMessage="* Select Requires Budget" Style="z-index: 106; left: 670px;
position: absolute; top: 51px" Display="None" ValidationGroup="actionsave"/>
</td>
</tr>
<tr>
<td class="smallFont" style="top: 284px; position: absolute;">Show on schedule? </td>
<td style="top: 0px; left: 105px; position: absolute;">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" Height="26px"
ReadOnly="true" Width="220px" RepeatDirection="Horizontal" style="top: 281px; position: absolute;"
AutoPostBack="false" SelectedValue='<%# Bind("ShowOnScheduleFlag") %>'
>
<asp:ListItem Value="" Text="" style="display: none;" />
<asp:ListItem Value="True" Text="Yes" />
<asp:ListItem Value="False" Text="No" />
</asp:RadioButtonList>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator3" ControlToValidate="RadioButtonList1"
ErrorMessage="* Select Show on schedule" Style="z-index: 106; left: 670px;
position: absolute; top: 51px" Display="None" ValidationGroup="actionsave"/>
</tr>
<tr>
<td class="smallFont" style="top: 310px; position: absolute;">
Comment </td>
<td>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Comment") %>' Width="500px" style="top: 307px; left: 65px; position: absolute;">
</asp:TextBox></td>
</tr>
<tr>
<td align="right" colspan="2" rowspan="4" style="top: 340px; position: absolute; left: 300px;">
<asp:Button ID="btnUpdate" ValidationGroup="actionsave" Text='<%# (Container is GridEditFormInsertItem) ? "Insert (Task Save Required)" : "Update (Task Save Required)" %>'
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</asp:Button>
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
CommandName="Cancel"></asp:Button></td>
</tr>
</table>
</table>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
</div>
</asp:Panel>
</td>
<td> </td>
<td style="width: 980px; height: 200px;" >
<asp:ValidationSummary ID="vsSave" Width="204px" ValidationGroup="actionsave" Height="300px" runat="server" DisplayMode="List" Font-Bold="False" HeaderText="<b>Please correct the errors:</b><br>" />
</td>
</tr>
</table>
</div>
</telerik:RadPageView>
please help me as i could not able to find the button in code...
thanks.
1 Answer, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 20 Sep 2010, 06:09 AM
Hello Bharat,
You can access the DeleteButton using its ColumnUniqueName. Check out the following code snippet.
C#:
Also refer the following documentation.
Accessing cells and rows
Thanks,
Princy.
You can access the DeleteButton using its ColumnUniqueName. Check out the following code snippet.
C#:
protected
void
RadGrid1_ItemDataBound1(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
ImageButton btnDelete = (ImageButton)item[
"DeleteCommandColumn"
].Controls[0];
// accessing Delete Button
if
()
// your condition
{
btnDelete.Enabled =
false
;
}
}
}
Also refer the following documentation.
Accessing cells and rows
Thanks,
Princy.