Folks
- Environment VS 2008 SP1, RadControls for ASP.NET AJAX Q3 2009 SP1, WIN XP SP2, IE7.
I have a small Radgrid with 2 columns. I would like to know how to hide delete commanditem template link button while selecting certian rows in GridView. For example if I am selecting customer id's: "ANTON" or "BOLID", that delete link button should auto hide and I am selecting any other customer's that delete link button should be visibile/unhide.
Below is my code and attached is the screen printout of Grid Data Source. Thanks
GC_0620
- Environment VS 2008 SP1, RadControls for ASP.NET AJAX Q3 2009 SP1, WIN XP SP2, IE7.
I have a small Radgrid with 2 columns. I would like to know how to hide delete commanditem template link button while selecting certian rows in GridView. For example if I am selecting customer id's: "ANTON" or "BOLID", that delete link button should auto hide and I am selecting any other customer's that delete link button should be visibile/unhide.
Below is my code and attached is the screen printout of Grid Data Source. Thanks
GC_0620
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> |
| <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title></title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <telerik:RadScriptManager ID="RadScriptManager1" Runat="server"> |
| </telerik:RadScriptManager> |
| </div> |
| <asp:SqlDataSource ID="SqlDataSource1" runat="server" |
| ConnectionString="<%$ ConnectionStrings:NwindConnectionString %>" |
| DeleteCommand="DELETE FROM [Customers] WHERE (([CustomerID] = ?) OR ([CustomerID] IS NULL AND ? IS NULL))" |
| InsertCommand="INSERT INTO [Customers] ([CustomerID], [CompanyName]) VALUES (?, ?)" |
| ProviderName="<%$ ConnectionStrings:NwindConnectionString.ProviderName %>" |
| SelectCommand="SELECT CustomerID, CompanyName, postalcODE FROM Customers where LEFT(CustomerID,2) <= "CB" ORDER BY CustomerID" |
| UpdateCommand="UPDATE [Customers] SET [CompanyName] = ? WHERE (([CustomerID] = ?) OR ([CustomerID] IS NULL AND ? IS NULL))"> |
| <DeleteParameters> |
| <asp:Parameter Name="CustomerID" Type="String" /> |
| </DeleteParameters> |
| <UpdateParameters> |
| <asp:Parameter Name="CompanyName" Type="String" /> |
| <asp:Parameter Name="CustomerID" Type="String" /> |
| </UpdateParameters> |
| <InsertParameters> |
| <asp:Parameter Name="CustomerID" Type="String" /> |
| <asp:Parameter Name="CompanyName" Type="String" /> |
| </InsertParameters> |
| </asp:SqlDataSource> |
| <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" |
| GridLines="None" AllowPaging="True" AllowSorting="True"> |
| <MasterTableView DataSourceID="SqlDataSource1" CommandItemDisplay= "TopAndBottom" |
| AutoGenerateColumns="False" DataKeyNames="CustomerID"> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridBoundColumn DataField="CustomerID" DefaultInsertValue="" |
| HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" |
| UniqueName="CustomerID"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="CompanyName" DefaultInsertValue="" |
| HeaderText="CompanyName" SortExpression="CompanyName" UniqueName="CompanyName"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <CommandItemTemplate> |
| <div style="padding: 5px 5px;"> |
| Custom command item template for Grid: |
| <asp:linkbutton id="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Edit.gif" /> Edit selected</asp:LinkButton> |
| <asp:linkbutton id="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Update.gif" /> Update</asp:LinkButton> |
| <asp:linkbutton id="btnCancel" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Cancel.gif" /> Cancel editing</asp:LinkButton> |
| <asp:linkbutton id="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/AddRecord.gif" /> Add new</asp:LinkButton> |
| <asp:linkbutton id="LinkButton3" runat="server" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Insert.gif" /> Add this </asp:LinkButton> |
| <asp:linkbutton id="LinkButton1" OnClientClick="javascript:return confirm('Delete selected?')" |
| runat="server" CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Delete.gif" /> Delete selected Jobs</asp:LinkButton> |
| </div> |
| </CommandItemTemplate> |
| </MasterTableView> |
| <ClientSettings> |
| <Selecting AllowRowSelect="True" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
| </form> |
| </body> |
| </html> |