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

Grid and Form integration

1 Answer 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Adrian
Top achievements
Rank 1
Adrian asked on 22 Jun 2015, 03:35 PM

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 ?

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Jun 2015, 10:58 AM
Hello Adrian,

You can temporarily disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, etc.) and enable your script debugger (FireBug or F12) to see whether there is script error interfering.

In addition, you can check the following live samples:
http://demos.telerik.com/aspnet-ajax/dataform/application-scenarios/integration-with-radgrid/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/master-detail/defaultcs.aspx

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Adrian
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or