Hi there, I tried using the following example to create a simple grid with auto CRUD. It looks good but when I click the "update" button the edited fields just reset and nothing else happens.
http://www.telerik.com/community/code-library/aspnet-ajax/grid/automatic-operations-with-sqldatasource-control.aspx
I've had to programmatically add the datasource as my app is rocking a legacy connection string encription routine.
Here's my ASP page:
And the code behind to create the datasource:
I'm obviously doing something wrong, but I just don't know what it is.
Thanks for any help you can provide,
Kenyon.
http://www.telerik.com/community/code-library/aspnet-ajax/grid/automatic-operations-with-sqldatasource-control.aspx
I've had to programmatically add the datasource as my app is rocking a legacy connection string encription routine.
Here's my ASP page:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Edit_GovernanceContacts.aspx.vb"
Inherits="APSubmission.Edit_GovernanceContacts" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register TagPrefix="uc1" TagName="Menu" Src="Menu.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
id
=
"Head1"
runat
=
"server"
>
<
title
>Submission System</
title
>
</
head
>
<
body
style
=
"background-color: #f2ffff"
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
div
>
<
uc1:Menu
ID
=
"Menu1"
runat
=
"server"
></
uc1:Menu
>
</
div
>
<
div
style
=
"padding: 10px 0 0 10px"
>
Edit Governance Contacts
<
telerik:RadGrid
ID
=
"gridContacts"
runat
=
"server"
AllowAutomaticDeletes
=
"True"
EnableAJAX
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
Skin
=
"WebBlue"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
DataKeyNames
=
"recID"
CommandItemDisplay
=
"TopAndBottom"
>
<
EditFormSettings
>
<
EditColumn
UniqueName
=
"EditCommandColumn"
></
EditColumn
>
</
EditFormSettings
>
<
Columns
>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditCommandColumn"
ButtonType
=
"imagebutton"
/>
<
telerik:GridBoundColumn
DataField
=
"recID"
FilterControlAltText
=
"Filter columnID column"
HeaderText
=
"ID"
UniqueName
=
"recID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"submissionSetID"
FilterControlAltText
=
"Filter columnSubmissionSet column"
HeaderText
=
"Submission Set ID"
UniqueName
=
"submissionSetID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"contactName"
FilterControlAltText
=
"Filter columnContactName column"
HeaderText
=
"Contact Name"
UniqueName
=
"contactName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"addDate"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter columnAddDate column"
HeaderText
=
"Add Date"
ReadOnly
=
"True"
UniqueName
=
"addDate"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"addWho"
FilterControlAltText
=
"Filter columnAddWho column"
HeaderText
=
"Add Who"
ReadOnly
=
"True"
UniqueName
=
"addWho"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
UniqueName
=
"ButtonColumn"
Text
=
"Delete"
CommandName
=
"Delete"
ButtonType
=
"LinkButton"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
div
>
</
form
>
</
body
>
</
html
>
And the code behind to create the datasource:
Protected
Sub
gridContacts_NeedDataSource(sender
As
Object
, e
As
Telerik.Web.UI.GridNeedDataSourceEventArgs)
Handles
gridContacts.NeedDataSource
Dim
myDataSource
As
New
SqlDataSource
myDataSource.ConnectionString = _functions.GetConnectionString()
myDataSource.DeleteCommand =
"delete GovernanceContact where recID = @recID"
myDataSource.InsertCommand =
"insert GovernanceContact (submissionSetID, contactName, addDate, addWho) values @submissionSetID, @contactName, @addDate, @addWho)"
myDataSource.SelectCommand =
"select * from GovernanceContact where submissionSetID = @submissionSetID"
myDataSource.UpdateCommand =
"update GovernanceContact set contactName = @contactName where recID = @recID"
myDataSource.DeleteParameters.Add(
"recID"
, DbType.Int32)
myDataSource.InsertParameters.Add(
"submissionSetID"
, DbType.Int32, _editSubmissionSetID)
myDataSource.InsertParameters.Add(
"contactName"
, DbType.
String
)
myDataSource.InsertParameters.Add(
"addDate"
, DbType.DateTime)
myDataSource.InsertParameters.Add(
"addWho"
, DbType.
String
)
myDataSource.SelectParameters.Add(
"submissionSetID"
, DbType.Int32, _editSubmissionSetID)
myDataSource.UpdateParameters.Add(
"contactName"
, DbType.
String
)
myDataSource.UpdateParameters.Add(
"recID"
, DbType.Int32)
gridContacts.DataSource = myDataSource
gridContacts.MasterTableView.DataSource = myDataSource
End
Sub
I'm obviously doing something wrong, but I just don't know what it is.
Thanks for any help you can provide,
Kenyon.