NP2322
asked on
DeleteCommand in GridView Not Responding
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:Connecti onString %>"
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.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Connecti
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.
ASKER
just left work, i'll get it on here on Monday.
Thanks!
Thanks!
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 "OldValuesParameterFormatS tring="ori ginal_" defined.
Paul
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 "OldValuesParameterFormatS
Paul
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Gridview source:
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False "
CellPadding="4" DataSourceID="SqlDataSourc e1" 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="Permission Name" />
<asp:BoundField DataField="LastLoginDate" HeaderText="LastLoginDate" SortExpression="LastLoginD ate" />
</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 "OldValuesParameterFormatS tring="ori ginal_", didn't seem to work. Any other ideas?
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False
CellPadding="4" DataSourceID="SqlDataSourc
<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"
<asp:BoundField DataField="LastLoginDate" HeaderText="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 "OldValuesParameterFormatS
can you post your gridview source as well?
Cheers!
Dani