Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DeleteCommand in GridView Not Responding

Posted on 2006-10-27
6
Medium Priority
?
1,724 Views
Last Modified: 2008-01-09
I have a gridview on me .aspx page and i'm trying to get the deletecommand to work. When i click it, the page gets refreshed but the item i clicked to delete remains both on the page and in the database. Below is an example of my source. I had it working at one point and then I changed some things around and it stopped responding.

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT [UserName], [Email], [PermissionName], [LastLoginDate] FROM [vw_aspnet_UserInfo]"
            Deletecommand="DELETE FROM aspnet_Users WHERE UserName = @original_UserName">
            <DeleteParameters >
                <asp:Parameter Name="original_UserName" Type="String" />
            </DeleteParameters>
       
        </asp:SqlDataSource>

Does anyone see where i'm going wrong or what i could be doing differently? I'm new to ASP.Net and so i'm still trying to get a hold of things.
0
Comment
Question by:NP2322
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 9

Expert Comment

by:daniel_balla
ID: 17822738
Hi NP2322,
can you post your gridview source as well?

Cheers!
Dani
0
 

Author Comment

by:NP2322
ID: 17822939
just left work, i'll get it on here on Monday.

Thanks!
0
 
LVL 6

Expert Comment

by:rhencullen
ID: 17822972
Check the definition of your SqlDataSource.

If you're not using optimistic  concurrency, but have an updatable key-column then In the definition for your SqlDataSource you need to make sure that you have "OldValuesParameterFormatString="original_" defined.

Paul
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:craskin
ID: 17823243
rhen is probably right. the reason you see the page refresh is because the datasource is running the sql, but there's nothing telling it what that parameter is, so it doesn't delete anything.
0
 
LVL 1

Accepted Solution

by:
samme earned 1000 total points
ID: 17826385
You can also try adding  ", UserName" in the datakeynames property of the gridview
0
 

Author Comment

by:NP2322
ID: 17833858
Gridview source:

                    <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                        CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None">
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <Columns>
                            <asp:CommandField ShowDeleteButton="True" />
                            <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" />
                            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                            <asp:BoundField DataField="PermissionName" HeaderText="PermissionName" SortExpression="PermissionName" />
                            <asp:BoundField DataField="LastLoginDate" HeaderText="LastLoginDate" SortExpression="LastLoginDate" />
                        </Columns>
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <EditRowStyle BackColor="#999999" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    </asp:GridView>


I tried adding "OldValuesParameterFormatString="original_", didn't seem to work. Any other ideas?
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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

705 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