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

Help with simple radgrid insert, update, delete

2 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
SIT
Top achievements
Rank 1
SIT asked on 17 Mar 2009, 05:12 AM
I must be missing something really basic.  I have created a table in sql server 2008 called mytest with two fields (mytest_id int identity, mytest_name nvarchar max).  I am trying to use radgrid to be able to insert, update, and delete.  I am using Visual Studio 2008 to create a web application project.  I have added the radscriptmanager, radgrid, and radajaxpanel.  I created the datasource to the mytest table on sql server and added the select, insert, update, and delete sql statements:


Select:  SELECT mytest_id, mytest_name FROM mytest
Update:  UPDATE mytest SET mytest_name = @mytest_name WHERE (mytest_id = @mytest_id)
Insert:  INSERT INTO mytest(mytest_name) VALUES (@mytest_name)
Delete:  DELETE FROM mytest WHERE (mytest_id = @mytest_id)

I have added the Select, Edit Update Cancel, and Delete columns.
I have set AllowAutomaticDeletes, AllowAutomaticInserts, AllowAutomaticUpdates all to true.

I think the commands are failing because there is no values for the @variables
If I change the delete command to:  DELETE FROM mytest WHERE (mytest_id = 1)
the record is successfully deleted.

Any help is appreciated,
Dave




2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Mar 2009, 09:37 AM
Hi Dave,

Can you check whether you have set the Delete parameters? Also check whether you have set 'mytest_id' as the DataKeyName for the RadGrid. If this does not help consider sending the entire aspx code.

You can also refer the following code library submission which explains how to perform automatic operations using SqlDataSource.
Automatic operations with SqlDataSource control

Thanks
Shinu.



0
SIT
Top achievements
Rank 1
answered on 18 Mar 2009, 03:07 AM
the datakeynames entry of mytest_id fixed the problem.  thanks!

Tags
Grid
Asked by
SIT
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
SIT
Top achievements
Rank 1
Share this question
or