Hi all,
here is the problem I ran into while seeing how far I could complicate a demo and then got stumpd :-)
I wanted a detailsview with ofcourse its own datasource but then use the demo example of the 3 comboboxes to limit user options when editing. As far as I can tell a externalcallpage is best.
However I dont know if should put the javascript on the externalcallbackpage or on the default page with the detailsview using findcontrol?
The second part Im not sure about is what goes into the backend of the default page. I found a couple examples for a Grid view but I think that has gotten me more lost than not. Was wondering if someone could do a quick example of hadling the 3 combobox demo nested in a detailsview? As I have never used a externalcallbackpage and only simple detailsviews.
Thanks in advance for any help
Anon
here is the problem I ran into while seeing how far I could complicate a demo and then got stumpd :-)
I wanted a detailsview with ofcourse its own datasource but then use the demo example of the 3 comboboxes to limit user options when editing. As far as I can tell a externalcallpage is best.
However I dont know if should put the javascript on the externalcallbackpage or on the default page with the detailsview using findcontrol?
The second part Im not sure about is what goes into the backend of the default page. I found a couple examples for a Grid view but I think that has gotten me more lost than not. Was wondering if someone could do a quick example of hadling the 3 combobox demo nested in a detailsview? As I have never used a externalcallbackpage and only simple detailsviews.
Thanks in advance for any help
Anon
6 Answers, 1 is accepted
0

Anon
Top achievements
Rank 1
answered on 21 Nov 2008, 09:52 AM
here is the code that I have started but like I said Im probably not close to a solution as I keep getting errors.
aspx
VB
aspx
<%@ Page Language="VB" MasterPageFile="~/EditPages/MasterPage.master" AutoEventWireup="false" |
CodeFile="Copy of EditProject.aspx.vb" Inherits="EditPages_EditProject" Title="Untitled Page" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<asp:Content ID="Content4" ContentPlaceHolderID="Main" runat="Server"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
</telerik:RadScriptManager> |
<telerik:RadCodeBlock ID="Codeblock" runat="server"> |
<script type="text/javascript"> |
function CloseAndRebind() |
{ |
GetRadWindow().Close(); |
GetRadWindow().BrowserWindow.refreshGrid(null); |
} |
function GetRadWindow() |
{ |
var oWindow = null; |
if (window.radWindow) oWindow = window.radWindow; |
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; |
return oWindow; |
} |
function CancelEdit() |
{ |
GetRadWindow().Close(); |
} |
function LoadTitle(combo, eventarqs) |
{ |
var titleCombo = document.getElementById('<%=DetailsView1.FindControl("RadComboBox5").ClientID %>'); |
var personCombo = document.getElementById('<%=DetailsView1.FindControl("RadComboBox6").ClientID %>'); |
var item = eventarqs.get_item(); |
titleCombo.set_text("Loading..."); |
personCombo.clearSelection(); |
if (item.get_index() > 0) |
{ |
titleCombo.requestItems(item.get_value(), false); |
} |
else |
{ |
titleCombo.set_text(" "); |
titleCombo.clearItems(); |
personCombo.set_text(" "); |
personCombo.clearItems(); |
} |
} |
function LoadPerson(combo, eventarqs) |
{ |
var titleCombo = document.getElementById('<%=DetailsView1.FindControl("RadComboBox5").ClientID %>'); |
var personCombo = document.getElementById('<%=DetailsView1.FindControl("RadComboBox6").ClientID %>'); |
var item = eventarqs.get_item(); |
personCombo.set_text("Loading..."); |
personCombo.requestItems(item.get_value(), false); |
} |
function ItemsLoaded(combo, eventarqs) |
{ |
var titleCombo = document.getElementById('<%=DetailsView1.FindControl("RadComboBox5").ClientID %>'); |
var personCombo = document.getElementById('<%=DetailsView1.FindControl("RadComboBox6").ClientID %>'); |
if (combo.get_items().get_count() > 0) |
{ |
combo.set_text(combo.get_items().getItem(0).get_text()); |
combo.get_items().getItem(0).highlight(); |
} |
combo.showDropDown(); |
} |
</script> |
</telerik:RadCodeBlock> |
<asp:Label ID="Edit" runat="server" Text="EDIT PROJECT"></asp:Label> |
<asp:DetailsView ID="DetailsView1" DataKeyNames="ProjectID" runat="server" DefaultMode="Edit" |
AutoGenerateRows="False" DataSourceID="EditProject" Height="50px" Width="100%" |
OnItemUpdated="DetailsView1_RowUpdate"> |
<Fields> |
<asp:TemplateField HeaderText="Project ID :"> |
<ItemTemplate> |
<telerik:RadTextBox runat="server" ID="ProjectID" Text='<%#Eval("ProjectID") %>' |
ReadOnly="true" Width="40px"> |
</telerik:RadTextBox> |
</ItemTemplate> |
</asp:TemplateField> |
<asp:TemplateField HeaderText="Project Title :"> |
<ItemTemplate> |
<telerik:RadTextBox ID="Title" runat="server" Text='<%#Bind("ProjectTitel") %>'> |
</telerik:RadTextBox> |
</ItemTemplate> |
</asp:TemplateField> |
<asp:TemplateField HeaderText=" Project Deadline :"> |
<ItemTemplate> |
<telerik:RadDateTimePicker ID="TextBox2" ValidationGroup="ww" runat="server" SharedCalenderID="" |
Culture="English (United States)" Skin="WebBlue" DbSelectedDate='<%#Bind("ProjectDeadline") %>'> |
<DateInput LabelCssClass="radLabelCss_WebBlue" Skin="WebBlue" runat="server"> |
</DateInput> |
</telerik:RadDateTimePicker> |
<asp:Label ID="ProjectDeadline" runat="server" Text='<%#Eval("ProjectDeadline") %>'></asp:Label> |
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" |
ErrorMessage="*" ValidationGroup="ww"></asp:RequiredFieldValidator> |
</ItemTemplate> |
</asp:TemplateField> |
<asp:TemplateField HeaderText="Priority"> |
<ItemTemplate> |
<telerik:RadComboBox ID="RadComboBox1" AppendDataBoundItems="true" runat="server" |
Skin="Office2007" SkinsPath="~/RadControls/ComboBox/Skins" Width="150px" DataValueField="Priority" |
DataSourceID="comboPriority" DataTextField="Priority" SelectedValue='<%#Bind("Priority")%>'> |
<Items> |
<telerik:RadComboBoxItem runat="server" Text="Low" Value="1" /> |
<telerik:RadComboBoxItem runat="server" Text="Medium" Value="2" /> |
<telerik:RadComboBoxItem runat="server" Text="High" Value="3" /> |
</Items> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</telerik:RadComboBox> |
</ItemTemplate> |
</asp:TemplateField> |
<asp:TemplateField HeaderText="From Group"> |
<ItemTemplate> |
<telerik:RadComboBox ID="RadComboBox4" runat="server" Skin="Office2007" SkinsPath="~/RadControls/ComboBox/Skins" DataSource="<%#LoadGroup()%> |
SelectedValue='<%#Bind("RGroup") %>' Width="150px" DataTextField="Display" DataValueField="RGroup" |
/> |
</ItemTemplate> |
</asp:TemplateField> |
<asp:TemplateField HeaderText="From Title"> |
<ItemTemplate> |
<telerik:RadComboBox ID="RadComboBox5" runat="server" Skin="Office2007" SkinsPath="~/RadControls/ComboBox/Skins" |
SelectedValue='<%#Bind("RTitle") %>' Width="150px" AllowCustomText="false" MarkFirstMatch="true" DataSource="<%#LoadTitle()%> |
DataTextField="RTitle" DataValueField="RTitle" |
/> |
</ItemTemplate> |
</asp:TemplateField> |
<asp:TemplateField HeaderText="From Name"> |
<ItemTemplate> |
<telerik:RadComboBox ID="RadComboBox6" runat="server" Skin="Office2007" SkinsPath="~/RadControls/ComboBox/Skins" |
SelectedValue='<%#Bind("RPerson") %>' Width="150px" AllowCustomText="false" MarkFirstMatch="true"DataSource="<%#LoadPerson()%> |
DataTextField="RPerson" DataValueField="RPerson" |
/> |
</ItemTemplate> |
</asp:TemplateField> |
<asp:TemplateField HeaderText="Discription"> |
<ItemTemplate> |
<telerik:RadTextBox TextMode="MultiLine" ID="TextBox1" Width="400px" Height="200px" |
ScrollBars="Vertical" runat="server" Text='<%#Bind("ProjectDiscpt") %>' /> |
</ItemTemplate> |
</asp:TemplateField> |
<asp:CommandField ShowEditButton="True" /> |
</Fields> |
</asp:DetailsView> |
<asp:SqlDataSource ID="EditProject" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" |
DeleteCommand="DELETE FROM [Projects] WHERE [ProjectID] = @ProjectID" InsertCommand="INSERT INTO [Projects] ([ProjectDeadline], [ProjectTitel], [ProjectDiscpt], [Priority],[Catagory], [RGroup], [RPerson], [LastEdit] VALUES (@ProjectDeadline, @ProjectTitel, @ProjectDiscpt, @Complete, @Priority, @Catagory, @RGroup, @RPerson, @LastEdit )" |
SelectCommand="SELECT Projects.ProjectID, Projects.ProjectDeadline, Projects.PDateOfCreate, Projects.ProjectTitel, Projects.ProjectDiscpt, Projects.Creater, Projects.MemberID, Projects.Complete, Projects.Priority, Projects.Approved, Projects.EditRights, Projects.Catagory, Projects.RGroup, Projects.RPerson, Projects.LastEdit, Projects.CompleteDate, Projects.EditBy, Project_Assign.MemberID AS Expr1 FROM Projects INNER JOIN Project_Assign ON Projects.ProjectID = Project_Assign.ProjectID WHERE (Projects.ProjectID = @ProjectID)" |
UpdateCommand="UPDATE [Projects] SET [ProjectDeadline] = @ProjectDeadline, [ProjectTitel] = @ProjectTitel, [ProjectDiscpt] = @ProjectDiscpt, [Priority] = @Priority, [Catagory] = @Catagory, [RGroup] = @RGroup, [RPerson] = @RPerson, [LastEdit]=@LastEdit WHERE [ProjectID] = @ProjectID"> |
<SelectParameters> |
<asp:QueryStringParameter Name="ProjectID" QueryStringField="ProjectID" Type="Int32" /> |
</SelectParameters> |
<DeleteParameters> |
<asp:Parameter Name="ProjectID" Type="Int32" /> |
</DeleteParameters> |
<UpdateParameters> |
<asp:Parameter Name="ProjectDeadline" Type="DateTime" /> |
<asp:Parameter Name="ProjectTitel" Type="String" /> |
<asp:Parameter Name="ProjectDiscpt" Type="String" /> |
<asp:Parameter Name="Priority" Type="String" /> |
<asp:Parameter Name="Catagory" Type="String" /> |
<asp:Parameter Name="RGroup" Type="String" /> |
<asp:Parameter Name="RPerson" Type="String" /> |
<asp:Parameter Name="LastEdit" Type="DateTime" DefaultValue="2008-07-12" /> |
<asp:Parameter Name="ProjectID" Type="Int32" /> |
</UpdateParameters> |
<InsertParameters> |
<asp:Parameter Name="ProjectDeadline" Type="DateTime" /> |
<asp:Parameter Name="ProjectTitel" Type="String" /> |
<asp:Parameter Name="ProjectDiscpt" Type="String" /> |
<asp:Parameter Name="Complete" /> |
<asp:Parameter Name="Priority" Type="String" /> |
<asp:Parameter Name="Catagory" Type="String" /> |
<asp:Parameter Name="RGroup" Type="String" /> |
<asp:Parameter Name="RPerson" Type="String" /> |
<asp:Parameter Name="LastEdit" /> |
</InsertParameters> |
</asp:SqlDataSource> |
<asp:SqlDataSource ID="comboPriority" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" |
SelectCommand="SELECT DISTINCT Priority_Type.Name FROM Projects INNER JOIN Priority_Type ON Projects.Priority = Priority_Type.Priority WHERE (Projects.Priority = @Priority)" |
runat="server"> |
<SelectParameters> |
<asp:QueryStringParameter Name="Priority" QueryStringField="Priority" /> |
</SelectParameters> |
</asp:SqlDataSource> |
</asp:Content> |
VB
Imports System |
Imports System.Data |
Imports System.Data.SqlClient |
Imports Telerik.Web.UI |
Imports Telerik.Web.UI.RadComboBox |
Partial Class EditPages_EditProject |
Inherits System.Web.UI.Page |
Protected Sub LoadGroup() |
Dim RadComboBox4 As RadComboBox = DirectCast(DetailsView1.FindControl("RadComboBox4"), RadComboBox) |
Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString) |
connection.Open() |
Dim adapter As New SqlDataAdapter("SELECT Distinct RGroup, Display FROM Directory", connection) |
Dim dt As New DataTable() |
adapter.Fill(dt) |
connection.Close() |
DirectCast(DetailsView1.FindControl("RadComboBox4"), RadComboBox).DataSource = dt |
DirectCast(DetailsView1.FindControl("RadComboBox4"), RadComboBox).DataBind() |
DirectCast(DetailsView1.FindControl("RadComboBox4"), RadComboBox).Items.Insert(0, New RadComboBoxItem("- Select a Group -")) |
For Each item As RadComboBoxItem In DirectCast(DetailsView1.FindControl("RadComboBox4"), RadComboBox).Items |
item.ToolTip = item.Text |
Next |
End Sub |
Protected Sub LoadTitle(ByVal RGroup As String) |
Dim RadComboBox5 As RadComboBox = DirectCast(DetailsView1.FindControl("RadComboBox5"), RadComboBox) |
Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString) |
connection.Open() |
Dim adapter As New SqlDataAdapter("SELECT Distinct RTitle FROM Directory WHERE RGroup=@RGroup", connection) |
adapter.SelectCommand.Parameters.AddWithValue("@RGroup", RGroup) |
Dim dt As New DataTable() |
adapter.Fill(dt) |
connection.Close() |
RadComboBox5.DataTextField = "RTitle" |
RadComboBox5.DataValueField = "RTitle" |
RadComboBox5.DataSource = dt |
RadComboBox5.DataBind() |
For Each item As RadComboBoxItem In RadComboBox5.Items |
item.ToolTip = item.Text |
Next |
End Sub |
Protected Sub LoadPerson(ByVal Title As String) |
Dim RadComboBox6 As RadComboBox = DirectCast(DetailsView1.FindControl("RadComboBox6"), RadComboBox) |
Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString) |
connection.Open() |
Dim adapter As New SqlDataAdapter("Select RPerson From Directory where RTitle=@RTitle", connection) |
adapter.SelectCommand.Parameters.AddWithValue("@RTitle", Title) |
connection.Close() |
Dim dt As New DataTable() |
adapter.Fill(dt) |
RadComboBox6.DataTextField = "RPerson" |
RadComboBox6.DataValueField = "RPerson" |
RadComboBox6.DataSource = dt |
RadComboBox6.DataBind() |
For Each item As RadComboBoxItem In RadComboBox6.Items |
item.ToolTip = item.Text |
Next |
End Sub |
Protected Sub RadComboBox4_ItemsRequested(ByVal o As Object, ByVal e As RadComboBoxItemsRequestedEventArgs) |
LoadGroup() |
End Sub |
Protected Sub RadComboBox5_ItemsRequested(ByVal o As Object, ByVal e As RadComboBoxItemsRequestedEventArgs) |
LoadTitle(e.Text) |
End Sub |
Protected Sub RadComboBox6_ItemsRequested(ByVal o As Object, ByVal e As RadComboBoxItemsRequestedEventArgs) |
LoadPerson(e.Text) |
End Sub |
Protected Sub Page_load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load |
If Not Page.IsPostBack Then |
End If |
EditProject.UpdateParameters("LastEdit").DefaultValue = Date.Now |
End Sub |
Protected Overrides Sub OnInit(ByVal e As System.EventArgs) |
InitializeComponent() |
MyBase.OnInit(e) |
End Sub |
Private Sub InitializeComponent() |
End Sub |
Protected Sub DetailsView1_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewCommandEventArgs) Handles DetailsView1.ItemCommand |
If (e.CommandName = "Update") Then |
ClientScript.RegisterClientScriptBlock(Page.GetType(), "mykey", "CloseAndRebind();", True) |
Else |
ClientScript.RegisterClientScriptBlock(Page.GetType(), "mykey", "CancelEdit();", True) |
End If |
End Sub |
Sub DetailsView1_RowUpdate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs) |
'Dim Member As DetailsViewRow |
' Dim chkGView As System.Web.UI.WebControls.CheckBoxList |
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly) |
Try |
Dim Approved As String = "Review" |
Dim Complete As Boolean = 0 |
Dim EditRights As Boolean = 1 |
Dim ProjectID As Telerik.Web.UI.RadTextBox = DetailsView1.FindControl("ProjectID") |
Dim ProjectDeadline As Telerik.Web.UI.RadDateTimePicker = DetailsView1.FindControl("TextBox2") |
Dim Priority As Telerik.Web.UI.RadComboBox = DetailsView1.FindControl("RadComboBox1") |
Dim RGroup As Telerik.Web.UI.RadComboBox = DetailsView1.FindControl("RadComboBox4") |
Dim LastEdit As DateTime = DateTime.Now |
Dim ProjectDiscpt As Telerik.Web.UI.RadTextBox = DetailsView1.FindControl("TextBox1") |
Dim RPerson As Telerik.Web.UI.RadTextBox = DetailsView1.FindControl("FromPerson") |
Dim Title As Telerik.Web.UI.RadTextBox = DetailsView1.FindControl("Title") |
Dim Catagory As Telerik.Web.UI.RadComboBox = DetailsView1.FindControl("RadComboBox2") |
Dim query As String = "Select Scope_Identity()" |
Dim connect As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" |
Dim conn As New SqlConnection(connect) |
Dim cmd As New SqlCommand("sp_UpdateProjects", conn) |
cmd.CommandType = CommandType.StoredProcedure |
cmd.Parameters.Add("@Approved", SqlDbType.VarChar).Value = Approved |
cmd.Parameters.Add("@Complete", SqlDbType.Bit).Value = Complete |
cmd.Parameters.Add("@EditRights", SqlDbType.Bit).Value = EditRights |
cmd.Parameters.Add("@ProjectID", SqlDbType.Int).Value = ProjectID.Text |
cmd.Parameters.Add("@ProjectTitle", SqlDbType.NVarChar).Value = Title.Text |
cmd.Parameters.AddWithValue("@ProjectDeadline", SqlDbType.DateTime).Value = ProjectDeadline.SelectedDate |
cmd.Parameters.Add("@Priority", SqlDbType.Int).Value = Priority.SelectedValue |
cmd.Parameters.Add("@Catagory", SqlDbType.NVarChar).Value = Catagory.SelectedValue |
cmd.Parameters.Add("@RGroup", SqlDbType.NVarChar).Value = RGroup.SelectedValue |
cmd.Parameters.Add("@LastEdit", SqlDbType.DateTime).Value = LastEdit |
cmd.Parameters.Add("@ProjectDiscpt", SqlDbType.NVarChar).Value = ProjectDiscpt.Text |
cmd.Parameters.Add("@RPerson", SqlDbType.NVarChar).Value = RPerson.Text |
conn.Open() |
cmd.ExecuteNonQuery() |
conn.Close() |
Catch ex As Exception |
Common.createErrorLog(Server.MapPath("../Logs/"), "Error ====> " & ex.Message & " Time Occured:" & DateTime.Now & " Page: " & Request.FilePath()) |
End Try |
End Sub |
End Class |
0
Hello Anon,
It seem you are using RadComboBox for ASP.NET AJAX so I am moving this thread to the appropriate forum.
ExternalCallBack page property is used in the "classic" RadComboBox, so you do not need it in your case.
Please check again our example on how to obtain the reference to the combobox, because currently you are using
var titleCombo = document.getElementById('<%=DetailsView1.FindControl("RadComboBox5").ClientID %>');
while it should be
var titleCombo = $find('<%=DetailsView1.FindControl("RadComboBox5").ClientID %>');
I hope this will get you started.
Best wishes,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
It seem you are using RadComboBox for ASP.NET AJAX so I am moving this thread to the appropriate forum.
ExternalCallBack page property is used in the "classic" RadComboBox, so you do not need it in your case.
Please check again our example on how to obtain the reference to the combobox, because currently you are using
var titleCombo = document.getElementById('<%=DetailsView1.FindControl("RadComboBox5").ClientID %>');
while it should be
var titleCombo = $find('<%=DetailsView1.FindControl("RadComboBox5").ClientID %>');
I hope this will get you started.
Best wishes,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Anon
Top achievements
Rank 1
answered on 26 Nov 2008, 10:44 AM
Thanks for the reply!
I had tried both, using both the example and the one I posted However I still get the same error from the page regarding finding the Rad combobox in the backend
throws the error
"selection out of range, parameter name: value"
however I have used it before with asp checkboxes and it work fine,
Anon
I had tried both, using both the example and the one I posted However I still get the same error from the page regarding finding the Rad combobox in the backend
Dim RadComboBox4 As RadComboBox = DirectCast(DetailsView1.FindControl("RadComboBox4"), RadComboBox) |
throws the error
"selection out of range, parameter name: value"
however I have used it before with asp checkboxes and it work fine,
Anon
0
Hi Anon,
I believe the best way to proceed is to send us a sample running project that exhibits the problem.
You need to open a support ticket to do that.
Thanks
Kind regards,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I believe the best way to proceed is to send us a sample running project that exhibits the problem.
You need to open a support ticket to do that.
Thanks
Kind regards,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

License Developer
Top achievements
Rank 1
answered on 16 Jan 2009, 05:53 PM
Was this resolved? I am trying to implement something like this.
0

Anon
Top achievements
Rank 1
answered on 18 Jan 2009, 09:00 AM
I never turned it in for review, as I work with mobile applications and flash, it was me seeing what I could do in asp.net. However if Telerik releases a demo, I would still be interested to see it. Sorry I can't help more, good luck!
-Anon
-Anon