This is a migrated thread and some comments may be shown as answers.

autogenerate delete column with multiple datakeys?

2 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 05 Jan 2009, 09:51 PM
Hi all, got a grid that displays a Rolename, RoleID and UserID for a particular user, based on the selected row of another grid.
Works fine.

Now, I want to autogenerate the delete button for the many-many table from that grid.

I have 
DeleteCommand="DELETE FROM UserxRole WHERE (UserID = @UserID) AND (RoleID = @RoleID)">
in my SqlDataSource

and

<DeleteParameters>
<asp:ControlParameter ControlID="gridUsersRoles" ConvertEmptyStringToNull="False" DefaultValue="" Name="UserID"  PropertyName="MasterTableView.DataKeyNames("UserID")"/>
<asp:ControlParameter ControlID="gridUsersRoles" ConvertEmptyStringToNull="False" DefaultValue="" Name="RoleID"  PropertyName="MasterTableView.DataKeyNames("RoleID")"/>
</DeleteParameters>

as my parms, but it doesn't like the long PropertyName
Am I missing the simple route to do this?
Or do I need to create a couple of hidden controls to store the two IDs in?

I'm only doing this the declaritive way as I have several more of these to do.
Any advice on the fastest way is welcomed.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Jan 2009, 06:04 AM
Hi Bob,

Go through the following code ilbrary link which demonstrates how to perform AutomaticOperations using  Delete Parameter.
Automatic operations with SqlDataSource control

Shinu

0
Bob
Top achievements
Rank 1
answered on 06 Jan 2009, 02:53 PM
Thanks, that gave me enough to make the delete work.
Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Bob
Top achievements
Rank 1
Share this question
or