Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
XML
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:CommandField ShowDeleteButton="True" />
                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Size" HeaderText="Size" SortExpression="Size" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:abcConnectionString %>"
            DeleteCommand="DELETE FROM Footwear WHERE (ID = @ID)"
            SelectCommand="SELECT * FROM [Footwear]">
            <DeleteParameters>
                <asp:Parameter Name="ID" />
            </DeleteParameters>
        </asp:SqlDataSource>
    </div>
    </form>
</body>


I cant delete from the Grid view...help me out
Posted
Updated 6-Jan-11 3:33am
v2
Comments
Vineet_2109 6-Jan-11 9:30am    
Hello Friends
I cant delete from the Grid view...help me out..
[no name] 6-Jan-11 9:35am    
You'll have to provide a bit more detail than this. What do you mean "can't delete"? Do you get an exception? Does it just not work?
Vineet_2109 6-Jan-11 9:47am    
Must declare the scalar variable "@ID".

this was exception...
what else do you required.. ??
Tarun.K.S 6-Jan-11 10:56am    
You will have to specify an SqlParameter for ID.

@ID is never declared or set to any value. Where should @ID be getting its value?
 
Share this answer
 
v2
Comments
Vineet_2109 6-Jan-11 11:42am    
Ya..thats true...
Set Datakey value as ID in the gridview
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900