0
嗨,我有一個gridview,鏈接到sqldatasource。我添加了一個存儲過程以從多個表中刪除,然後啓用刪除GridView智能標記。使用存儲過程從gridview刪除
當我點擊刪除按鈕,我收到一條錯誤消息,「對象必須實現IConvertible」。我讀過這是將參數傳遞給存儲過程的問題,可能是傳遞了錯誤的數據類型。林不知道我是否將參數傳遞給存儲過程。參數應該是gridviews datakeyname,在這種情況下它是「UserId」。
存儲過程的工作我精細管理工作室,所以我認爲這僅僅是傳遞的參數(或可能不被通過)
我是不是要代碼後面的代碼要傳遞給參數存儲過程?
<asp:SqlDataSource ID="selectUsers" runat="server" ConnectionString="<%$ ConnectionStrings:CASSFConnectionString %>"
SelectCommand="SELECT aspnet_Membership.UserId, aspnet_Membership.IsLockedOut, aspnet_Membership.Email, aspnet_Membership.CreateDate, aspnet_Membership.LastLoginDate, aspnet_Membership.LastPasswordChangedDate, aspnet_Profile.PropertyValuesString, aspnet_Users.UserName, aspnet_Membership.IsApproved FROM aspnet_Membership INNER JOIN aspnet_Profile ON aspnet_Membership.UserId = aspnet_Profile.UserId INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId AND aspnet_Profile.UserId = aspnet_Users.UserId WHERE (CONVERT (nvarchar(256), aspnet_Profile.PropertyValuesString) = @district)"
DeleteCommand="DeleteUsers" DeleteCommandType="StoredProcedure" UpdateCommand="UPDATE [aspnet_Membership] SET [IsApproved] = @IsApproved, [Email] = @email, [IsLockedOut] = @IsLockedOut WHERE [aspnet_Membership].[UserId] = @UserID">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="district" PropertyName="SelectedValue" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="UserId" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="IsApproved" />
<asp:Parameter Name="email" />
<asp:Parameter Name="IsLockedOut" />
<asp:Parameter Name="UserID" />
</UpdateParameters>
</asp:SqlDataSource>
你應該能夠在sql數據源的刪除參數中指定用戶標識。一些代碼將有助於說明您的問題。 – Phaedrus
謝謝。我已經添加了我的SqlDataSource。如果使用存儲過程,我可以在這裏設置參數。 – Tones