Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

deletecommand current row

Posted on 2011-05-10
4
Medium Priority
?
203 Views
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?
0
Comment
Question by:runnerjp2005
  • 2
4 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35727512
are you using <asp:SqlDataSource

then refer this
http://msdn.microsoft.com/en-us/library/ms972940.aspx
0
 

Author Comment

by:runnerjp2005
ID: 35727525
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">
                         <SelectParameters>
          <asp:QueryStringParameter Name="forum" QueryStringField="fn" />
        </SelectParameters>
              </asp:AccessDataSource>
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 2000 total points
ID: 35727543
0
 
LVL 16

Expert Comment

by:Rose Babu
ID: 35727602

Hi,

set ID as a DataKeyName for a grid

<asp:GridView DataKeyNames="ID" ID="GridView1" 
     runat="server" AutoGenerateColumns="False" 
     OnRowCommand="GridView1_RowCommand" 
     OnRowDataBound="GridView1_RowDataBound"
     OnRowDeleted="GridView1_RowDeleted" 
     OnRowDeleting="GridView1_RowDeleting">

Open in new window


on clicking delete

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

  DeleteRecordByID(ID); 

}

Open in new window

Happy Programming.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

578 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