deletecommand current row

Posted on 2011-05-10
Last Modified: 2012-05-11
How would i put together my delete string for current row

DeleteCommand="DELETE * FROM [forum] WHERE ID= ???

not sure how to add the current row id here?
Question by:runnerjp2005
    LVL 39

    Expert Comment

    by:Pratima Pharande
    are you using <asp:SqlDataSource

    then refer this

    Author Comment

    i am using

    <asp:AccessDataSource ID="AccessDataSource1" runat="server"
                      DataFile="~/forums/forum.mdb" SelectCommand="SELECT * FROM [forum] WHERE Forum=@forum AND numrep = 0 ORDER by important,lasttime DESC">
              <asp:QueryStringParameter Name="forum" QueryStringField="fn" />
    LVL 39

    Accepted Solution

    LVL 16

    Expert Comment

    by:Rose Babu


    set ID as a DataKeyName for a grid

    <asp:GridView DataKeyNames="ID" ID="GridView1" 
         runat="server" AutoGenerateColumns="False" 

    Open in new window

    on clicking delete

    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
      int ID = (int) GridView1.DataKeys[e.RowIndex].Value;

    Open in new window

    Happy Programming.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now