www.webdeveloper.com
Results 1 to 3 of 3

Thread: How can I make the delete button in a datagrid disabled ?

  1. #1
    Join Date
    Sep 2005
    Posts
    109

    How can I make the delete button in a datagrid disabled ?

    Hello,
    I want to make some delete buttons in a datagrid disabled. How can I do it ? Thanks.

  2. #2
    Join Date
    Sep 2004
    Location
    Northeast, FL
    Posts
    332
    If you are using a template item, then you could do something as simple as:

    Code:
    <script runat="server">
            Public Function AllowDelete(ByVal propToAnalyze As String) As String
                Select Case propToAnalyze
                    Case "Apples"
                        Return False.ToString
                    Case "Bananas"
                        Return True.ToString
                End Select
            End Function
        </script>
        <asp:DataGrid ID="MyDataGrid" runat="server">
            <Columns>
                <asp:TemplateColumn>
                    <ItemTemplate>
                        <asp:Button ID="DeleteButton" runat="server" Enabled='<%# AllowDelete(Eval("aDataBoundField")) %>' />
                    </ItemTemplate>
                </asp:TemplateColumn>
            </Columns>
        </asp:DataGrid>
    Otherwise if you want to have a lot of control of the template column and be able to reuse it on other grids, then look into extending the System.Web.UI.WebControls.TemplateColumn class. This method is powerfull and if you use it then you'll likely see potential for new ideas on how you can use datagrids as well.

  3. #3
    Join Date
    Sep 2005
    Posts
    109
    Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles