I'm trying to write a grid and form where the form will display the data for the line selected on the grid.
Grid and DS
<
telerik:RadGrid
ID
=
"GridPeople"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
DataSourceID
=
"SQLDSPeople"
GroupPanelPosition
=
"Top"
>
<
ClientSettings
EnablePostBackOnRowClick
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
DataSourceID
=
"SQLDSPeople"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"person_ref"
visible
=
"false"
UniqueName
=
"person_ref"
/>
<
telerik:GridBoundColumn
DataField
=
"forename1"
FilterControlAltText
=
"Filter"
HeaderText
=
"Forename"
UniqueName
=
"forename"
/>
<
telerik:GridBoundColumn
DataField
=
"surname"
FilterControlAltText
=
"Filter"
HeaderText
=
"Surname"
UniqueName
=
"surname"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SQLDSPeople"
runat
=
"server"
ProviderName
=
"System.Data.SqlClient"
SelectCommand
=
"SELECT [person_ref], [forename1 ], [surname] FROM [PERSON] "
/>
With just this, everything works find, I can select different rows and the row highlights and the code behind event gets called.
Here's the dataform and its DS.
<
telerik:RadDataForm
ID
=
"FormPerson"
runat
=
"server"
DataKeyNames
=
"person_ref"
DataSourceID
=
"SQLDSPerson"
>
<
LayoutTemplate
>
<
div
id
=
"itemPlaceholder"
runat
=
"server"
></
div
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
fieldset
>
<
div
>
<
asp:Label
runat
=
"server"
ID
=
"FirstNameLabel2"
Text
=
"First Name:"
></
asp:Label
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"FirstNameTextBox2"
Text='<%# Bind("forename1")%>' MaxLength="20" />
</
div
>
<
div
>
<
asp:Label
runat
=
"server"
ID
=
"LastNameLabel2"
Text
=
"Last Name:"
></
asp:Label
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"LastNameTextBox2"
Text='<%# Bind("surname")%>' MaxLength="20" />
</
div
>
<
div
>
<
telerik:RadButton
ID
=
"ButtonUpdate"
Text
=
"Update"
runat
=
"server"
CommandName
=
"Update"
/>
</
div
>
</
fieldset
>
</
ItemTemplate
>
</
telerik:RadDataForm
>
<
asp:SqlDataSource
ID
=
"SQLDSPerson"
runat
=
"server"
ProviderName
=
"System.Data.SqlClient"
SelectCommand
=
"SELECT [person_ref], [forename1], [surname] FROM [PERSON] WHERE ([person_ref] = @person_ref)"
UpdateCommand
=
"UPDATE [PERSON] SET [forename1] = @forename1, [surname] = @surname WHERE [person_ref] = @person_ref"
>
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"GridPeople"
Name
=
"person_ref"
PropertyName
=
"SelectedValue"
Type
=
"String"
/>
</
SelectParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"forename1"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"surname"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"person_ref"
Type
=
"String"
/>
</
UpdateParameters
>
</
asp:SqlDataSource
>
As soon as I add this, the grid select row stops working and no events are fired. Also, the grid doesn't appear at all.
Here's the code behind bits.
Private
Sub
Page_Init1(sender
As
Object
, e
As
EventArgs)
Handles
Me
.Init
SQLDSPeople.ConnectionString = MyConnStr
SQLDSPerson.ConnectionString = MyConnStr
End
Sub
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
If
Not
IsPostBack
Then
GridPeople.SelectedIndexes.Add(0)
End
If
End
Sub
Private
Sub
GridPeople_SelectedIndexChanged(sender
As
Object
, e
As
EventArgs)
Handles
GridPeople.SelectedIndexChanged
FormPerson.Rebind()
End
Sub
Private
Sub
FormPerson_ItemUpdated(sender
As
Object
, e
As
Telerik.Web.UI.RadDataFormUpdatedEventArgs)
Handles
FormPerson.ItemUpdated
GridPeople.Rebind()
End
Sub
Am I doing something wrong in the RadDataForm ?