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

[Solved] RadGrid and 2 datasources

3 Answers 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robbie
Top achievements
Rank 1
Robbie asked on 17 Apr 2009, 10:21 AM
Hi all,

I have a RadGrid with a nested table inside. On the main table I have a SqlDataSource with a join clause by which I am trying to retrieve address details from our CRM package, based upon the choice from a GridDropDownColumn. I then need to update a seperate DB with the information.

The datasource details are as follows:

<

 

asp:SqlDataSource ID="SqlDataSource1" runat="server"

 

ConnectionString="<%$ ConnectionStrings:Trident_SLURPConnectionString %>"

 

DeleteCommand="DELETE FROM [Core_Support] WHERE [IssueNumber] = @IssueNumber"

 

InsertCommand="INSERT INTO [Core_Support] ([Customer], [InitialContact], [InitialEngineer], [AddressName], [AddressNumber], [AddressStreet1], [AddressStreet2], [AddressStreet3], [AddressCity], [AddressCounty], [AddressCountry], [AddressPostCode]) VALUES (@Customer, @InitialContact, @InitialEngineer, @AddressName, @AddressNumber, @AddressStreet1, @AddressStreet2, @AddressStreet3, @AddressCity, @AddressCounty, @AddressCountry, @AddressPostCode)"

 

SelectCommand="SELECT * FROM [Core_Support] ORDER BY [IssueNumber]"
SELECT [Address1_Name], [Address1_Line1], [Address1_Line2], [Address1_Line3], [Address1_City], [Address1_County], [Address1_PostalCode], [Address1_Country] FROM Trident_Professional_IT_Services_MSCRM.dbo.Account as CRM

join Core_Support as CS on CS.Customer =CRM.Name"

 

 

 

UpdateCommand="UPDATE [Core_Support] SET [Customer] = @Customer, [InitialContact] = @InitialContact, [InitialEngineer] = @InitialEngineer, [AddressName] = @AddressName, [AddressNumber] = @AddressNumber, [AddressStreet1] = @AddressStreet1, [AddressStreet2] = @AddressStreet2, [AddressStreet3] = @AddressStreet3, [AddressCity] = @AddressCity, [AddressCounty] = @AddressCounty, [AddressCountry] = @AddressCountry, [AddressPostCode] = @AddressPostCode WHERE [IssueNumber] = @IssueNumber">

 

<DeleteParameters>

 

<asp:Parameter Name="IssueNumber" Type="Decimal" />

 

</DeleteParameters>

 

<UpdateParameters>

 

<asp:Parameter Name="Customer" Type="String" />

 

<asp:Parameter Name="InitialContact" Type="String" />

 

<asp:Parameter Name="InitialEngineer" Type="String" />

 

<asp:Parameter Name="AddressName" Type="String" />

 

<asp:Parameter Name="AddressNumber" Type="Int32" />

 

<asp:Parameter Name="AddressStreet1" Type="String" />

 

<asp:Parameter Name="AddressStreet2" Type="String" />

 

<asp:Parameter Name="AddressStreet3" Type="String" />

 

<asp:Parameter Name="AddressCity" Type="String" />

 

<asp:Parameter Name="AddressCounty" Type="String" />

 

<asp:Parameter Name="AddressCountry" Type="String" />

 

<asp:Parameter Name="AddressPostCode" Type="String" />

 

<asp:Parameter Name="IssueNumber" Type="Decimal" />

 

</UpdateParameters>

 

<InsertParameters>

 

<asp:Parameter Name="Customer" Type="String" />

 

<asp:Parameter Name="InitialContact" Type="String" />

 

<asp:Parameter Name="InitialEngineer" Type="String" />

 

<asp:Parameter Name="AddressName" Type="String" />

 

<asp:Parameter Name="AddressNumber" Type="Int32" />

 

<asp:Parameter Name="AddressStreet1" Type="String" />

 

<asp:Parameter Name="AddressStreet2" Type="String" />

 

<asp:Parameter Name="AddressStreet3" Type="String" />

 

<asp:Parameter Name="AddressCity" Type="String" />

 

<asp:Parameter Name="AddressCounty" Type="String" />

 

<asp:Parameter Name="AddressCountry" Type="String" />

 

<asp:Parameter Name="AddressPostCode" Type="String" />

 

</InsertParameters>

 

</asp:SqlDataSource>


I also need the edit form fields which are outlined in the parameters above, to be automatically filled a selection is made in  the GridDropDownBox.

Obviously, it's not working. What am I doing wrong?

:-)

 

 

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 22 Apr 2009, 10:23 AM
Hello Robbie,

The built-in functionality of the RadGrid allows it to work with only one DataContext. In other words if the grid is bound to one Table it is not attainable to update the other table's values. If you need achieve this functionality I will suggest using of a UserControl for edit form, which will allow you to get the DataItem of the row and to populate the UserControl in way which suits your needs. Please review this online help article which shows how to pass the DataItem to the User control :
http://www.telerik.com/help/aspnet-ajax/grdcustomeditforms.html
You need also to examine this online demo which uses user control to edit the values. You can update values in a second DataContext through this user control.

In connection with your second question:
Could you clarify what functionality you are searching for? Is it required when a selection from the GridDropDownColumn is made to populate the nested grid and set its rows in edit mode?

Kind regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Robbie
Top achievements
Rank 1
answered on 06 May 2009, 02:04 PM
Hi Georgi,

"Is it required when a selection from the GridDropDownColumn is made to populate the nested grid and set its rows in edit mode?"

That is nearly correct. When I am in the edit form, I have a dropdown and some normal text box entry controls. When a selection is made from the dropdown box, I need the other fields in the edit form to be populated with values from the SQL DB (the address) corresponding to the dropdown.

I am not a coder and need to do this with as little, or no coding if possible.

Many thanks for your help with this,

Robbie
0
Georgi Krustev
Telerik team
answered on 11 May 2009, 11:01 AM
Hello Robbie,

Unfortunately there is no a code-less solution, which can attain this functionality.

One possible resolution of this issue is to retrieve the auto-generated grid editors, or the form template (if you are not using auto-generated one), and to populate them according to the DropDownList's selected value.

Please examine the following online help articles:
Two-way declarative binding,
Updating values using UserControl/FormTemplate,
Automatic DataSource operations

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Robbie
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Robbie
Top achievements
Rank 1
Share this question
or