RE: Q - About Edit and Delete buttons in DataGrid

Discussion in 'ASP .Net' started by Mike Moore [MSFT], Oct 20, 2003.

  1. Hi Ather,

    You want to do this in the ItemDataBound event.

    I created a datagrid based on the pubs database. I then used the
    ItemDataBound event to prevent editing the author with the last name Green
    and prevented updating the author with the last name "Dull". My first
    column is my edit column and my ItemDataBound event is as follows:

    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    DataGrid1.ItemDataBound
    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
    ListItemType.AlternatingItem Then
    If e.Item.DataItem("au_lname") = "Green" Then
    CType(e.Item.Cells(0).Controls(0), Control).Visible = False
    End If
    End If
    If e.Item.ItemType = ListItemType.EditItem Then
    If e.Item.DataItem("au_lname") = "Dull" Then
    CType(e.Item.Cells(0).Controls(0), Control).Visible = False
    End If
    End If
    End Sub

    -----
    I hope this helps.

    Thank you, Mike
    Microsoft, ASP.NET Support Professional

    Microsoft highly recommends to all of our customers that they visit the
    http://www.microsoft.com/protect site and perform the three straightforward
    steps listed to improve your computer’s security.

    This posting is provided "AS IS", with no warranties, and confers no rights.


    --------------------
    > From: "Ather Ali Shaikh" <>
    > Subject: Q - About Edit and Delete buttons in DataGrid
    > Date: Fri, 17 Oct 2003 12:11:44 +0500
    > Lines: 20
    > X-Priority: 3
    > X-MSMail-Priority: Normal
    > X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
    > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
    > Message-ID: <eVk#>
    > Newsgroups: microsoft.public.dotnet.framework.aspnet
    > NNTP-Posting-Host: super13-line-154.super.net.pk 203.130.13.154
    > Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
    > Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:185319
    > X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    > hi,
    > I am using a datareader to assign to the datagrid in my ASP.Net Page

    using
    > VB.Net
    >
    > I have stored procedure to retrieve the data.
    > In the datareader I have a field fldStage
    > I want to hide Edit and Delete buttons in the DataGrid When fldStage = 1
    > What should I do and in Which method of DataGrid?
    >
    > Thanx in Adavanced.
    >
    > --
    > Ather Ali Shaikh
    > Software Engineer
    > eIntelligence (Pvt.) Limited.
    > Ph. (+92-21) 2434070, 2415929-30
    > email.
    > web. www.eintelligencesoft.com
    >
    >
    >
     
    Mike Moore [MSFT], Oct 20, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Schultz
    Replies:
    3
    Views:
    571
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Feb 14, 2005
  2. Kevin Frey
    Replies:
    3
    Views:
    1,109
    Kevin Frey
    Nov 27, 2006
  3. Andy B
    Replies:
    0
    Views:
    325
    Andy B
    May 21, 2008
  4. Rudy

    EDIT & DELETE grid buttons don't work

    Rudy, Jan 6, 2005, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    133
  5. Ather Ali Shaikh

    Q. About Show and Hide Edit and Delete Buttons

    Ather Ali Shaikh, Oct 16, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    134
    Ather Ali Shaikh
    Oct 16, 2003
Loading...

Share This Page