Andy Green
Top achievements
Rank 1
Andy Green
asked on 28 May 2010, 11:41 AM
Hi All
I have a FormTemplate, with several linked RadComboBoxes, I have this working for insert, ie when a user adds a new record that select a value from the first dropdown, which in turn populated the second, they select a value from the second which populates the third. As I say this all works fine.
Now, whe I edit a record, I have to take the ID from the first dropdown and use this to populate the second then set its selected value to that in the database, then use this secected value to populate the third dropdown.
I assume the correct event to do this is the EditCommand, how do I get a handle on the controls from this event?
ANdy
I have a FormTemplate, with several linked RadComboBoxes, I have this working for insert, ie when a user adds a new record that select a value from the first dropdown, which in turn populated the second, they select a value from the second which populates the third. As I say this all works fine.
Now, whe I edit a record, I have to take the ID from the first dropdown and use this to populate the second then set its selected value to that in the database, then use this secected value to populate the third dropdown.
I assume the correct event to do this is the EditCommand, how do I get a handle on the controls from this event?
ANdy
12 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 28 May 2010, 01:25 PM
Hello Andy,
You cannot access the control inside editform in EditCommand event. If you want to populate second RadComboBox based on the selected value of first RadComboBox, then you can use SelectedIndexChanged event of first combo. Inside the event, using NamingContainer property of combo, access the container (GridEditFormItem) and then use FindControl() method to access the second combobox.
Hope this information helps you.
Regards,
Shinu.
You cannot access the control inside editform in EditCommand event. If you want to populate second RadComboBox based on the selected value of first RadComboBox, then you can use SelectedIndexChanged event of first combo. Inside the event, using NamingContainer property of combo, access the container (GridEditFormItem) and then use FindControl() method to access the second combobox.
Hope this information helps you.
Regards,
Shinu.
0
Andy Green
Top achievements
Rank 1
answered on 28 May 2010, 01:30 PM
Hi
There is no selectedindexchanged event fired. The Radcombobox must populate from the database value of the first Radcombobox, and then select itself. This selected value (from the database) then sets up the third Radcombobox.
There is no clicking, this is done when the user creates a new record and works OK.
What I need to do is recreate the conditions in edit mode that existed when the user saved the original record.
Andy
There is no selectedindexchanged event fired. The Radcombobox must populate from the database value of the first Radcombobox, and then select itself. This selected value (from the database) then sets up the third Radcombobox.
There is no clicking, this is done when the user creates a new record and works OK.
What I need to do is recreate the conditions in edit mode that existed when the user saved the original record.
Andy
0
Andy Green
Top achievements
Rank 1
answered on 02 Jun 2010, 02:22 PM
Anyone?
0
Hello Andy,
In this case, you can setup an editForm template, and directly assign the datasources to the combo box controls, as well as setup the select parameters for the datasource controls.
The other option is to assign and use the SelectedIndexChanged event handlers to setup data for the related controls.
I hope that these options are feasible for you.
Kind regards,
Yavor
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items.
In this case, you can setup an editForm template, and directly assign the datasources to the combo box controls, as well as setup the select parameters for the datasource controls.
The other option is to assign and use the SelectedIndexChanged event handlers to setup data for the related controls.
I hope that these options are feasible for you.
Kind regards,
Yavor
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items.
0
Andy Green
Top achievements
Rank 1
answered on 24 Jun 2010, 01:22 PM
Thanks, I have done this, but I cant get the actual current data values that are in the database (currently in the recordset). I need these to use for the selected values for the radcombos
How do I do this?
Andy
How do I do this?
Andy
0
Hello Andy,
I have followed your scenario and prepared a sample project implementing it. You can find it attached to this message.
Please take a look at it and let me know whether it helps.
All the best,
Mira
the Telerik team
I have followed your scenario and prepared a sample project implementing it. You can find it attached to this message.
Please take a look at it and let me know whether it helps.
All the best,
Mira
the Telerik team
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 Public Issue Tracking
system and vote to affect the priority of the items
0
Andy Green
Top achievements
Rank 1
answered on 29 Jun 2010, 01:51 PM
Hi Mira
This is still not what I'm looking for. Assume that the database contains the previously saved values from the RadComboBoxes. Also bearing in mind that the second combo box is dependant on the first. What has to happen is that the first ComboBox gets it value form the database, I then have to load all possible values for the second combo box and select the value, this then drives a third, so I have to get all possible values for the third combo box and select the value.
What I'm having trouble with is gettnig the actual data value from the previous combobox to drive the next.
ASPX Page
I have also included my commented out code showing my attempts.
Hope this helps explain, otherwise I'll raise a support ticket, but please be quick my years support runs out in 2 weeks, and yes we are in the process of renewing at the better price, but things dont necessarily move that quick here.
Andy
PS ddlSite (which I can get) drives ddlMainwait which drives ddlSubwait.
This is still not what I'm looking for. Assume that the database contains the previously saved values from the RadComboBoxes. Also bearing in mind that the second combo box is dependant on the first. What has to happen is that the first ComboBox gets it value form the database, I then have to load all possible values for the second combo box and select the value, this then drives a third, so I have to get all possible values for the third combo box and select the value.
What I'm having trouble with is gettnig the actual data value from the previous combobox to drive the next.
ASPX Page
<MasterTableView Name="Clinic" CommandItemDisplay="Top" EditMode="EditForms" DataKeyNames="OutcomeClinic_ID"> |
<Columns> |
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" EditImageUrl="../App_Themes/Images/Edit_16.gif" UpdateImageUrl="../App_Themes/Default/Grid/Update.gif" CancelImageUrl="../App_Themes/Default/Grid/Cancel.gif" InsertImageUrl="../App_Themes/Default/Grid/Update.gif" ItemStyle-Width="35px" HeaderStyle-Width="35px"></telerik:GridEditCommandColumn> |
<telerik:GridBoundColumn DataField="OutcomeClinic_ID" Visible="False"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="ClinicCode" HeaderText="Clinic" SortExpression="ClinicCode" UniqueName="ClinicCode"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="GroupName" HeaderText="Group Name" SortExpression="GroupName" UniqueName="GroupName"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Site" HeaderText="Site" SortExpression="Site" UniqueName="Site"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="MainWait" HeaderText="Main Wait" SortExpression="MainWait" UniqueName="MainWait"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="SubWait" HeaderText="Sub Wait" SortExpression="SubWait" UniqueName="SubWait"><HeaderStyle Font-Bold="True" /></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Comments" Visible="False"></telerik:GridBoundColumn> |
<telerik:GridCheckBoxColumn DataField="IsCancerClinic" HeaderText="Cancer Clinic" SortExpression="IsCancerClinic" UniqueName="IsCancerClinic"><HeaderStyle Font-Bold="True" /></telerik:GridCheckBoxColumn> |
<telerik:GridCheckBoxColumn DataField="IsMPA" HeaderText="MPA" SortExpression="IsMPA" UniqueName="IsMPA"><HeaderStyle Font-Bold="True" /></telerik:GridCheckBoxColumn> |
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="Delete" ImageUrl="../App_Themes/Default/Grid/delete.gif" UniqueName="column" ConfirmDialogType="RadWindow" ConfirmText="Are you sure you want to delete this Site"><HeaderStyle Width="10px" /><ItemStyle Width="10px" /></telerik:GridButtonColumn> |
</Columns> |
<EditFormSettings EditFormType="Template"> |
<EditColumn CancelImageUrl="../App_Themes/Default/Grid/Cancel.gif" EditImageUrl="../App_Themes/Default/Grid/Edit.gif" InsertImageUrl="../App_Themes/Default/Grid/Update.gif" UpdateImageUrl="../App_Themes/Default/Grid/Update.gif" ButtonType="ImageButton" UniqueName="EditCommandColumn1" ></EditColumn> |
<FormTemplate> |
<div id="EditForm"> |
<table class="Container" width="100%" > |
<tr> |
<td>Clinic Code</td> |
<td> |
<asp:TextBox ID="txtClinicCode" runat="server" Width="30px" Text='<%# Bind("ClinicCode") %>' CssClass="TextBoxDecorator"></asp:TextBox></asp:TextBox> |
<asp:RequiredFieldValidator ID="rfvClinicCode" runat="server" ControlToValidate="txtClinicCode"><img src="../App_Themes/Images/Check_16.gif" alt="Missing Field" /></asp:RequiredFieldValidator> |
<asp:Label ID="lblClinicExists" runat="server" Text="Clinic already exists" CssClass="Warning" Visible="false"></asp:Label> |
</td> |
<td rowspan="5" valign="top"> |
<asp:CheckBox ID="chkCancer" runat="server" Text="Cancer Clinic" checked='<%# Bind("IsCancerClinic") %>' /> |
<br /> |
<asp:CheckBox ID="chkMPA" runat="server" Text="MPA" checked='<%# Bind("IsMPA") %>'/> |
</td> |
</tr> |
<tr> |
<td>Group Name</td> |
<td> |
<telerik:RadComboBox ID="ddlGroupName" runat="server" Width="200px" AppendDataBoundItems="true" ToolTip="Group Name" EnableEmbeddedSkins="False" Skin="OPTIMS" CausesValidation="false" SelectedValue='<%#Bind("GroupName_ID") %>'></telerik:RadComboBox> |
<asp:RequiredFieldValidator ID="rfvGroupName" runat="server" ControlToValidate="ddlGroupName"><img src="../App_Themes/Images/Check_16.gif" alt="Missing Field" /></asp:RequiredFieldValidator> |
</td> |
</tr> |
<tr> |
<td>Site</td> |
<td> |
<telerik:RadComboBox ID="ddlSite" runat="server" Width="200px" AutoPostBack="true" AppendDataBoundItems="true" ToolTip="Site" EnableEmbeddedSkins="False" Skin="OPTIMS" OnSelectedIndexChanged="UpdateMainWait" CausesValidation="false" SelectedValue='<%#Bind("Site_ID") %>'></telerik:RadComboBox> |
<asp:RequiredFieldValidator ID="rfvSite" runat="server" ControlToValidate="ddlSite"><img src="../App_Themes/Images/Check_16.gif" alt="Missing Field" /></asp:RequiredFieldValidator> |
</td> |
</tr> |
<tr> |
<td>Main Wait</td> |
<td> |
<telerik:RadComboBox ID="ddlMainWait" runat="server" Width="200px" AutoPostBack="true" AppendDataBoundItems="true" ToolTip="Main Wait" EnableEmbeddedSkins="False" Skin="OPTIMS" OnSelectedIndexChanged="UpdateSubWait" CausesValidation="false" ></telerik:RadComboBox> |
<asp:RequiredFieldValidator ID="rfvMainWait" runat="server" ControlToValidate="ddlMainWait"><img src="../App_Themes/Images/Check_16.gif" alt="Missing Field" /></asp:RequiredFieldValidator> |
</td> |
</tr> |
<tr> |
<td>Sub Wait</td> |
<td> |
<telerik:RadComboBox ID="ddlSubWait" runat="server" Width="200px" AppendDataBoundItems="true" ToolTip="Sub Wait" EnableEmbeddedSkins="False" Skin="OPTIMS" CausesValidation="false"></telerik:RadComboBox> |
<asp:RequiredFieldValidator ID="rfvSubWait" runat="server" ControlToValidate="ddlSubWait"><img src="../App_Themes/Images/Check_16.gif" alt="Missing Field" /></asp:RequiredFieldValidator> |
</td> |
</tr> |
<tr> |
<td>Comments</td> |
<td colspan="2"><asp:TextBox ID="txtComments" runat="server" Width="400px" CssClass="TextBoxDecorator" Text='<%# Bind("Comments") %>'></asp:TextBox></td> |
</tr> |
<tr> |
<td> </td> |
<td colspan="2"> |
<asp:Button ID="btnUpdate" cssclass="gridbtn_80" Text='<%#iif(TryCast(Container, GridItem).OwnerTableView.IsItemInserted, "Insert","Update") %>' runat="server" CommandName='<%# iif(TryCast(Container, GridItem).OwnerTableView.IsItemInserted, "PerformInsert", "Update" )%>'></asp:Button> |
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="False" cssclass="gridbtn_80" CommandName="Cancel"/> |
</td> |
</tr> |
</table> |
</div> |
</FormTemplate> |
</EditFormSettings> |
<CommandItemSettings AddNewRecordText="Add new Clinic" RefreshText=" " /> |
<RowIndicatorColumn><HeaderStyle Width="20px" /></RowIndicatorColumn> |
<ExpandCollapseColumn><HeaderStyle Width="20px" /></ExpandCollapseColumn> |
</MasterTableView> |
VB page
Protected Sub ddlOutcomeForm_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlOutcomeForm.SelectedIndexChanged |
rgClinics.Rebind() |
End Sub |
Protected Sub rgClinics_DeleteCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgClinics.DeleteCommand |
Dim whichGrid As String = e.Item.OwnerTableView.Name |
Select Case whichGrid |
Case "Clinic" |
Dim User_GUID As Guid = Security.ToGuid(Session("User_GUID")) |
Dim DeletedItem As GridDataItem = DirectCast(e.Item, GridDataItem) |
Dim Clinic_ID As Int32 = DeletedItem.OwnerTableView.DataKeyValues(DeletedItem.ItemIndex)("OutcomeClinic_ID") |
Try |
Dim x As New Admin |
x.ClinicDelete(Clinic_ID, User_GUID) |
Catch ex As Exception |
rgClinics.Controls.Add(New LiteralControl("Unable to delete Clinic Reason: " & ex.Message)) |
e.Canceled = True |
End Try |
End Select |
End Sub |
Protected Sub rgClinics_EditCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgClinics.EditCommand |
' Dim User_GUID As Guid = Security.ToGuid(Session("User_GUID")) |
' Dim InsertedItem As GridDataItem = DirectCast(e.Item, GridDataItem) |
' Dim Site_ID As Int32 = (CType(InsertedItem.FindControl("ddlSite"), RadComboBox).SelectedItem.Value) |
' |
' Dim ddlMainWait As RadComboBox = (CType(InsertedItem.FindControl("ddlMainwait"), RadComboBox)) |
'populate MainWait List |
' Dim mw As New CoreData |
' Dim mw_dt As DataTable = mw.LocationByParent(Site_ID, User_GUID) |
' If mw_dt.Rows.Count > 0 Then |
'With ddlMainWait |
'.Items.Insert(0, New RadComboBoxItem("")) |
' .DataSource = mw_dt |
' .DataValueField = "Location_ID" |
' .DataTextField = "Location" |
' .DataBind() |
' .SelectedValue = Site_ID |
' End With |
'End If |
End Sub |
Protected Sub rgClinics_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgClinics.NeedDataSource |
If Page.IsPostBack Then |
Dim User_GUID As Guid = Security.ToGuid(Session("User_GUID")) |
ClinicsGrid_Load(ddlOutcomeForm.SelectedValue, User_GUID) |
End If |
End Sub |
Protected Sub rgClinics_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgClinics.ItemCreated |
If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then |
Dim whichGrid As String = e.Item.OwnerTableView.Name |
Select Case whichGrid |
Case "Clinic" |
Dim User_GUID As Guid = Security.ToGuid(Session("User_GUID")) |
Dim editFormItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem) |
'populate GroupName List |
Dim OutcomeForm_ID = ddlOutcomeForm.SelectedValue |
Dim ddlGroupName As RadComboBox = DirectCast(editFormItem.FindControl("ddlGroupName"), RadComboBox) |
Dim GroupName As New Admin |
Dim GroupName_dt As DataTable = GroupName.GroupNameByOutcomeForm(OutcomeForm_ID, User_GUID) |
If GroupName_dt.Rows.Count > 0 Then |
With ddlGroupName |
.Items.Insert(0, New RadComboBoxItem("")) |
.DataSource = GroupName_dt |
.DataValueField = "OutcomeForm_ID" |
.DataTextField = "OutcomeFormName" |
End With |
End If |
'populate site List |
Dim ddlSite As RadComboBox = DirectCast(editFormItem.FindControl("ddlSite"), RadComboBox) |
Dim s As New CoreData |
Dim s_dt As DataTable = s.LocationByParent(0, User_GUID) |
If s_dt.Rows.Count > 0 Then |
With ddlSite |
.Items.Insert(0, New RadComboBoxItem("")) |
.DataSource = s_dt |
.DataValueField = "Location_ID" |
.DataTextField = "Location" |
End With |
End If |
End Select |
End If |
End Sub |
Protected Sub UpdateMainWait(ByVal sender As Object, ByVal e As System.EventArgs) |
Dim User_GUID As Guid = Security.ToGuid(Session("User_GUID")) |
Dim ddRow As RadComboBox = DirectCast(sender, RadComboBox) |
Dim editForm As GridEditFormItem = DirectCast(ddRow.NamingContainer, GridEditFormItem) |
Dim ddlMainWait As RadComboBox = DirectCast(editForm.FindControl("ddlMainWait"), RadComboBox) |
'populate MainWait List |
Dim mw As New CoreData |
Dim mw_dt As DataTable = mw.LocationByParent(sender.selectedvalue, User_GUID) |
If mw_dt.Rows.Count > 0 Then |
With ddlMainWait |
.Items.Insert(0, New RadComboBoxItem("")) |
.DataSource = mw_dt |
.DataValueField = "Location_ID" |
.DataTextField = "Location" |
.DataBind() |
End With |
End If |
End Sub |
Protected Sub UpdateSubWait(ByVal sender As Object, ByVal e As System.EventArgs) |
Dim User_GUID As Guid = Security.ToGuid(Session("User_GUID")) |
Dim ddRow As RadComboBox = DirectCast(sender, RadComboBox) |
Dim editForm As GridEditFormItem = DirectCast(ddRow.NamingContainer, GridEditFormItem) |
Dim ddlSubWait As RadComboBox = DirectCast(editForm.FindControl("ddlSubWait"), RadComboBox) |
'populate SubWait List |
Dim sw As New CoreData |
Dim sw_dt As DataTable = sw.LocationByParent(sender.selectedvalue, User_GUID) |
If sw_dt.Rows.Count > 0 Then |
With ddlSubWait |
.Items.Insert(0, New RadComboBoxItem("")) |
.DataSource = sw_dt |
.DataValueField = "Location_ID" |
.DataTextField = "Location" |
.DataBind() |
End With |
End If |
End Sub |
Protected Sub rgClinics_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgClinics.ItemCommand |
If e.CommandName = RadGrid.InitInsertCommandName Then |
e.Canceled = True |
Dim newValues As New System.Collections.Specialized.ListDictionary() |
newValues("IsCancerClinic") = 1 |
newValues("IsMPA") = 0 |
e.Item.OwnerTableView.InsertItem(newValues) |
End If |
End Sub |
Protected Sub rgClinics_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgClinics.InsertCommand |
Dim whichGrid As String = e.Item.OwnerTableView.Name |
Select Case whichGrid |
Case "Clinic" |
Dim User_GUID As Guid = Security.ToGuid(Session("User_GUID")) |
Dim InsertedItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem) |
Dim ClinicCode = New String(CType(InsertedItem.FindControl("txtClinicCode"), TextBox).Text).ToUpper |
Dim cc As New Admin |
Dim ClinicExists As String = cc.ClinicExistsCheck(ClinicCode, User_GUID) |
If Len(ClinicExists) = 0 Then |
Dim OutcomeForm_ID As Int32 = CInt(ddlOutcomeForm.SelectedItem.Value) |
Dim GroupName_ID As Int32 = (CType(InsertedItem.FindControl("ddlGroupName"), RadComboBox).SelectedItem.Value) |
Dim Site_ID As Int32 = (CType(InsertedItem.FindControl("ddlSite"), RadComboBox).SelectedItem.Value) |
Dim Mainwait_ID As Int32 = (CType(InsertedItem.FindControl("ddlMainwait"), RadComboBox).SelectedItem.Value) |
Dim Subwait_ID As Int32 = (CType(InsertedItem.FindControl("ddlSubwait"), RadComboBox).SelectedItem.Value) |
Dim Comments = New String(CType(InsertedItem.FindControl("txtComments"), TextBox).Text) |
Dim IsCancerClinic As Boolean = (CType(InsertedItem.FindControl("chkCancer"), CheckBox).Checked) |
Dim IsMPA As Boolean = (CType(InsertedItem.FindControl("chkMPA"), CheckBox).Checked) |
Try |
Dim x As New Admin |
x.ClinicInsert(OutcomeForm_ID, ClinicCode, GroupName_ID, Site_ID, Mainwait_ID, Subwait_ID, Comments, IsCancerClinic, IsMPA, User_GUID) |
Catch ex As Exception |
rgClinics.Controls.Add(New LiteralControl("Unable to add Clinic. Reason: " & ex.Message)) |
e.Canceled = True |
End Try |
'hide warning label in case it was shown |
Dim lblClinicExists As Label = CType(InsertedItem.FindControl("lblClinicExists"), Label) |
lblClinicExists.Text = "" |
lblClinicExists.Visible = False |
Else |
Dim lblClinicExists As Label = CType(InsertedItem.FindControl("lblClinicExists"), Label) |
lblClinicExists.Text = "Clinic exists - " + ClinicExists |
lblClinicExists.Visible = True |
e.Canceled = True |
End If |
End Select |
End Sub |
Protected Sub rgClinics_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgClinics.UpdateCommand |
Dim whichGrid As String = e.Item.OwnerTableView.Name |
Select Case whichGrid |
Case "Clinic" |
Dim User_GUID As Guid = Security.ToGuid(Session("User_GUID")) |
Dim ParentItem As GridDataItem = DirectCast(e.Item.OwnerTableView.ParentItem, GridDataItem) |
Dim UpdatedItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem) |
Dim Clinic_ID As Int32 = ParentItem.OwnerTableView.DataKeyValues(ParentItem.ItemIndex)("Clinic_ID") |
Dim ClinicCode = New String(CType(UpdatedItem.FindControl("txtClinicCode"), TextBox).Text) |
Dim GroupName_ID As Int32 = (CType(UpdatedItem.FindControl("ddlGroupName"), RadComboBox).SelectedItem.Value) |
Dim Site_ID As Int32 = (CType(UpdatedItem.FindControl("ddlSite"), RadComboBox).SelectedItem.Value) |
Dim Mainwait_ID As Int32 = (CType(UpdatedItem.FindControl("ddlMainwait"), RadComboBox).SelectedItem.Value) |
Dim Subwait_ID As Int32 = (CType(UpdatedItem.FindControl("ddlSubwait"), RadComboBox).SelectedItem.Value) |
Dim Comments = New String(CType(UpdatedItem.FindControl("txtComments"), TextBox).Text) |
Dim IsCancerClinic As Boolean = (CType(UpdatedItem.FindControl("chkCancer"), CheckBox).Checked) |
Dim IsMPA As Boolean = (CType(UpdatedItem.FindControl("chkMPA"), CheckBox).Checked) |
Try |
Dim x As New Admin |
x.ClinicUpdate(Clinic_ID, ClinicCode, GroupName_ID, Site_ID, Mainwait_ID, Subwait_ID, Comments, IsCancerClinic, IsMPA, User_GUID) |
Catch ex As Exception |
rgClinics.Controls.Add(New LiteralControl("Unable to add Clinic. Reason: " & ex.Message)) |
e.Canceled = True |
End Try |
End Select |
End Sub |
Protected Sub rgClinics_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgClinics.ItemDataBound |
'delete this sub |
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then |
'Dim RowDataItem As GridEditableItem = CType(e.Item, GridEditableItem) |
' Dim GroupName As RadComboBox = TryCast(RowDataItem.FindControl("ddlGroupName"), RadComboBox) |
' Dim data As System.Data.DataRowView = TryCast(e.Item.DataItem, System.Data.DataRowView) |
' Dim editItem As GridEditableItem = TryCast(e.Item, GridEditableItem) |
'Dim ddlPosition As DropDownList = DirectCast(editItem("position").FindControl("ddlPosition"), DropDownList) |
' Dim User_GUID As Guid = Security.ToGuid(Session("User_GUID")) |
' Dim InsertedItem As GridDataItem = DirectCast(e.Item, GridDataItem) |
' Dim Site_ID As Int32 = data("Site_ID") '(CType(InsertedItem.FindControl("ddlSite"), RadComboBox).SelectedItem.Value) |
'Dim ddlMainWait As RadComboBox = TryCast(e.Item.FindControl("ddlMainWait"), RadComboBox) |
'populate MainWait List |
'Dim mw As New CoreData |
'Dim mw_dt As DataTable = mw.LocationByParent(Site_ID, User_GUID) |
'If mw_dt.Rows.Count > 0 Then |
'With ddlMainWait |
'.Items.Insert(0, New RadComboBoxItem("")) |
' .DataSource = mw_dt |
' .DataValueField = "Location_ID" |
' .DataTextField = "Location" |
' .DataBind() |
' .SelectedValue = Site_ID |
' End With |
' End If |
End If |
End Sub |
I have also included my commented out code showing my attempts.
Hope this helps explain, otherwise I'll raise a support ticket, but please be quick my years support runs out in 2 weeks, and yes we are in the process of renewing at the better price, but things dont necessarily move that quick here.
Andy
PS ddlSite (which I can get) drives ddlMainwait which drives ddlSubwait.
0
Andy Green
Top achievements
Rank 1
answered on 29 Jun 2010, 03:01 PM
I now have this working after a fashion, could someone please review as I dont think this is the best way for 2 reasons.
1. I'm refering the datavalues by ordinal
2. The code fails if the comboboxes have their selected value changed, the code only works as the erro is in a try catch which ignores the error.
1. I'm refering the datavalues by ordinal
2. The code fails if the comboboxes have their selected value changed, the code only works as the erro is in a try catch which ignores the error.
Protected Sub rgClinics_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgClinics.ItemCreated |
If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then |
Dim whichGrid As String = e.Item.OwnerTableView.Name |
Select Case whichGrid |
Case "Clinic" |
Dim User_GUID As Guid = Security.ToGuid(Session("User_GUID")) |
Dim EditFormItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem) |
'populate GroupName List |
Dim OutcomeForm_ID = ddlOutcomeForm.SelectedValue |
Dim ddlGroupName As RadComboBox = DirectCast(EditFormItem.FindControl("ddlGroupName"), RadComboBox) |
Dim GroupName As New Admin |
Dim GroupName_dt As DataTable = GroupName.GroupNameByOutcomeForm(OutcomeForm_ID, User_GUID) |
If GroupName_dt.Rows.Count > 0 Then |
With ddlGroupName |
.Items.Insert(0, New RadComboBoxItem("")) |
.DataSource = GroupName_dt |
.DataValueField = "OutcomeForm_ID" |
.DataTextField = "OutcomeFormName" |
End With |
End If |
'populate site List |
Dim ddlSite As RadComboBox = DirectCast(EditFormItem.FindControl("ddlSite"), RadComboBox) |
Dim s As New CoreData |
Dim s_dt As DataTable = s.LocationByParent(0, User_GUID) |
If s_dt.Rows.Count > 0 Then |
With ddlSite |
.Items.Insert(0, New RadComboBoxItem("")) |
.DataSource = s_dt |
.DataValueField = "Location_ID" |
.DataTextField = "Location" |
End With |
End If |
''''''''''''''''''''''MY NEW CODE''''''''''''''''''''''''''' |
'this always errors after UpdateSubwait fires, it works at the moment as its in a try catch but needs to be fixed |
Try |
Dim Site_ID As Int32 = EditFormItem.DataItem.Row.Item(5) |
Dim MainWait_ID As Int32 = EditFormItem.DataItem.Row.Item(7) |
Dim SubWait_ID As Int32 = EditFormItem.DataItem.Row.Item(9) |
'populate Mainwait List based on Site |
Dim ddlMainWait As RadComboBox = DirectCast(EditFormItem.FindControl("ddlMainWait"), RadComboBox) |
Dim mw As New CoreData |
Dim mw_dt As DataTable = mw.LocationByParent(Site_ID, User_GUID) |
If s_dt.Rows.Count > 0 Then |
With ddlMainWait |
.Items.Insert(0, New RadComboBoxItem("")) |
.DataSource = mw_dt |
.DataValueField = "Location_ID" |
.DataTextField = "Location" |
.SelectedValue = MainWait_ID |
End With |
End If |
'populate Subwait List based on Mainwait |
Dim ddlSubWait As RadComboBox = DirectCast(EditFormItem.FindControl("ddlSubWait"), RadComboBox) |
Dim sw As New CoreData |
Dim sw_dt As DataTable = sw.LocationByParent(MainWait_ID, User_GUID) |
If s_dt.Rows.Count > 0 Then |
With ddlSubWait |
.Items.Insert(0, New RadComboBoxItem("")) |
.DataSource = sw_dt |
.DataValueField = "Location_ID" |
.DataTextField = "Location" |
.SelectedValue = SubWait_ID |
End With |
End If |
Catch ex As Exception |
End Try |
End Select |
End If |
End Sub |
0
Andy Green
Top achievements
Rank 1
answered on 01 Jul 2010, 08:11 AM
Hi I still need some help.
The page errors when i hit the cancel button. When the cancel button is clicked the rgEvent_ItemCreated if fired. Inside this sub I have
The page errors when i hit the cancel button. When the cancel button is clicked the rgEvent_ItemCreated if fired. Inside this sub I have
If
TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
End if
This line errors as Object variable or With block variable not set. - Dim Site_ID As Int32 = EditFormItem.DataItem.Row.Item(5)
What can I check for to stop this from erroring, and why when I hit cancel is the form still in edit Mode.
I currently have this in a try catch so the error is ignored, but that is not acceptable going forward.
Andy
0
Hello Andy,
I have modified the sample from my previous message to implement the desired functionality.
In the attached project the cascading RadComboBoxes are bound in the following way:
For additional information on related combos, please take a look at this demo.
If the issues persist, please open a formal support ticket and sent us a small working project, demonstrating your full setup and showing the unwanted behavior.
We will debug it locally and get back to you.
Thank you in advance for the cooperation.
All the best,
Mira
the Telerik team
I have modified the sample from my previous message to implement the desired functionality.
In the attached project the cascading RadComboBoxes are bound in the following way:
protected
void
RadGrid1_ItemCreated(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem editForm = e.Item
as
GridEditFormItem;
RadComboBox list = editForm.FindControl(
"RadComboBox1"
)
as
RadComboBox;
list.AutoPostBack =
true
;
list.SelectedIndexChanged +=
new
RadComboBoxSelectedIndexChangedEventHandler(list_SelectedIndexChanged);
}
}
void
list_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
GridEditFormItem editForm = (sender
as
RadComboBox).NamingContainer
as
GridEditFormItem;
RadComboBox ddList2 = editForm.FindControl(
"RadComboBox2"
)
as
RadComboBox;
DataTable table = GetRelatedRecords(
"SELECT distinct OrderID, Quantity FROM [Order Details] WHERE OrderID = "
+ (sender
as
RadComboBox).SelectedValue);
ddList2.DataValueField =
"Quantity"
;
ddList2.DataTextField =
"Quantity"
;
ddList2.DataSource = table;
ddList2.DataBind();
}
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem editForm = e.Item
as
GridEditFormItem;
RadComboBox list = editForm.FindControl(
"RadComboBox1"
)
as
RadComboBox;
DataTable table = GetRelatedRecords(
"SELECT distinct OrderID FROM [Order Details]"
);
list.DataTextField =
"OrderID"
;
list.DataValueField =
"OrderID"
;
list.DataSource = table;
list.SelectedValue = editForm[
"OrderID"
].Text;
list.DataBind();
RadComboBox ddList2 = editForm.FindControl(
"RadComboBox2"
)
as
RadComboBox;
table = GetRelatedRecords(
"SELECT distinct OrderID, Quantity FROM [Order Details] WHERE OrderID = "
+ editForm[
"OrderID"
].Text);
ddList2.DataValueField =
"Quantity"
;
ddList2.DataTextField =
"Quantity"
;
ddList2.DataSource = table;
ddList2.DataBind();
}
}
If the issues persist, please open a formal support ticket and sent us a small working project, demonstrating your full setup and showing the unwanted behavior.
We will debug it locally and get back to you.
Thank you in advance for the cooperation.
All the best,
Mira
the Telerik team
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 Public Issue Tracking
system and vote to affect the priority of the items
0
Andy Green
Top achievements
Rank 1
answered on 02 Jul 2010, 01:36 PM
Thanks again Mira but not quite right.
This line list.SelectedValue = editForm["OrderID"].Text; looks to the editform for the value, whereas in fact the value is in the recordset of the edited item - Not the editform
How do I access the dataset record. As I've described in my post updates I have this all working, but I'm not sure I'm using the correct methods.
I'll have to raise a ticket.
ANdy
This line list.SelectedValue = editForm["OrderID"].Text; looks to the editform for the value, whereas in fact the value is in the recordset of the edited item - Not the editform
How do I access the dataset record. As I've described in my post updates I have this all working, but I'm not sure I'm using the correct methods.
I'll have to raise a ticket.
ANdy
0
Hello Andy,
Our system indicates that you have opened a support ticket concerning the same issue. In order to avoid duplicate posts, I suggest that we continue the communication in the support ticket.
All the best,
Mira
the Telerik team
Our system indicates that you have opened a support ticket concerning the same issue. In order to avoid duplicate posts, I suggest that we continue the communication in the support ticket.
All the best,
Mira
the Telerik team
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 Public Issue Tracking
system and vote to affect the priority of the items