| <telerik:RadDateInput Label="Order Date:" width="700" ID="RadDateInput1" DateFormat="MM/dd/yy" ForeColor="GrayText" SelectedDate='<%#DateTime.Now%>' runat=server /> |
Folks,
I am trying to retain the values in a detail grid after a griddropdowncolumn event fire (selectedindexchanged event ). I am extracting the values (current cell values) of the grid in a session variable and changing some properties for a column depending on the selected value in dropdown in the selectedindexchanged event (then I am rebinding the grid to see the effects of changed properties). Then in grid prerender event I am trying to set the cell values from the session variable, Here comes the problem, I am unable to find the detail grid items to set the cell values.
I am binding the grid on the server (using needdatasource event and detailtablebind events).
For your reference, I have included my selectedindexchanged event and grid prerender events here
| Private Sub List_SelectedIndexChanged(ByVal sender As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs) |
| Dim editedItem As GridEditableItem = CType(CType(sender, RadComboBox).NamingContainer, GridEditableItem) |
| Dim ddlChsnMthd As RadComboBox = CType(editedItem("CHSN_MTHD_ID").Controls(0), RadComboBox) |
| Dim insertItem As GridDataItem = DirectCast(CType(sender, RadComboBox).NamingContainer, GridDataItem) |
| Dim insertVals As Hashtable = New Hashtable |
| RadGrid1.MasterTableView.ExtractValuesFromItem(insertVals, insertItem) |
| Session("insertvals") = insertVals |
| If ddlChsnMthd.SelectedValue = 4 Then |
| RadGrid1.MasterTableView.DetailTables.Item(0).Columns.Item(9).Visible = True |
| Else |
| RadGrid1.MasterTableView.DetailTables.Item(0).Columns.Item(9).Visible = False |
| End If |
| RadGrid1.MasterTableView.Rebind() |
| End Sub |
| Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender |
| If Not Session("insertvals") Is Nothing AndAlso RadGridTransCalc.MasterTableView.DetailTables.Item(0).IsItemInserted Then |
| Dim insertvals As Hashtable = CType(Session("insertvals"), Hashtable) |
| Dim insertItem As GridEditableItem = DirectCast(RadGridTransCalc.MasterTableView.DetailTables.Item(0).GetInsertItem(), GridEditableItem) |
| If Not insertvals("ID") Is Nothing Then TryCast(insertItem("ID").Controls(0), RadComboBox).SelectedValue = insertvals("ID") |
| If Not insertvals("CALC_DATE") Is Nothing Then TryCast(insertItem("CALC_DATE").Controls(0), RadDatePicker).SelectedDate = CDate(insertvals("CALC_DATE")) |
| If Not insertvals("STRT_TIME") Is Nothing Then TryCast(insertItem("STRT_TIME").Controls(0), RadTimePicker).SelectedDate = CDate(insertvals("STRT_TIME")) |
| If Not insertvals("END_TIME") Is Nothing Then TryCast(insertItem("END_TIME").Controls(0), RadTimePicker).SelectedDate = CDate(insertvals("END_TIME")) |
| If Not insertvals("COND_ID") Is Nothing Then TryCast(insertItem("COND_ID").Controls(0), RadComboBox).SelectedValue = insertvals("COND_ID") |
| If Not insertvals("MTHD_ID") Is Nothing Then TryCast(insertItem("MTHD_ID").Controls(0), RadComboBox).SelectedValue = insertvals("MTHD_ID") |
| End If |
| End Sub |
Kevin
| <telerik:RadContextMenu ID="radContextMenu1" runat="server" Skin="Forest" OnClientItemClicked="ClientItemClicked"> |
| <Items> |
| <telerik:RadMenuItem Text="Show Column"> |
| <Items> |
| <telerik:RadMenuItem Text="MDEP" /> |
| <telerik:RadMenuItem Text="MDEP Description" /> |
| <telerik:RadMenuItem Text="OA" /> |
| <telerik:RadMenuItem Text="OA Description" /> |
| <telerik:RadMenuItem Text="EOR" /> |
| <telerik:RadMenuItem Text="EOR Description" /> |
| <telerik:RadMenuItem Text="ASN" /> |
| <telerik:RadMenuItem Text="ASN Description" /> |
| <telerik:RadMenuItem Text="APC" /> |
| <telerik:RadMenuItem Text="APC Description" /> |
| <telerik:RadMenuItem Text="FY06" /> |
| <telerik:RadMenuItem Text="FY07" /> |
| <telerik:RadMenuItem Text="FY08" /> |
| <telerik:RadMenuItem Text="FY09" /> |
| </Items> |
| </telerik:RadMenuItem> |
| <telerik:RadMenuItem Text="Hide Column" /> |
| </Items> |
| <Targets> |
| <telerik:ContextMenuTagNameTarget TagName="thead" /> |
| </Targets> |
| </telerik:RadContextMenu> |
| function ClientItemClicked( sender, eventArgs ) { |
| activeTable = $find( "<%= radGrid1.ClientID %>" ).get_masterTableView(); |
| colIndex = GetRealCellIndex( activeTable, eventArgs.get_gridColumn().get_element()); |
| switch( eventArgs.get_item().get_text() ) { |
| case "MDEP" : |
| activeTable.showColumn( 0 ); |
| break; |
| case "MDEP Description" : |
| activeTable.showColumn( 1 ); |
| break; |
| case "OA" : |
| activeTable.showColumn( 2 ); |
| break; |
| case "OA Description" : |
| activeTable.showColumn( 3 ); |
| break; |
| case "EOR" : |
| activeTable.showColumn( 4 ); |
| break; |
| case "EOR Description": |
| activeTable.showColumn( 5 ); |
| break; |
| case "ASN": |
| activeTable.showColumn( 6 ); |
| break; |
| case "ASN Description": |
| activeTable.showColumn( 7 ); |
| break; |
| case "APC": |
| activeTable.showColumn( 8 ); |
| break; |
| case "APC Description": |
| activeTable.showColumn( 9 ); |
| break; |
| case "FY06": |
| activeTable.showColumn( 10 ); |
| break; |
| case "FY07": |
| activeTable.showColumn( 11 ); |
| break; |
| case "FY08": |
| activeTable.showColumn( 12 ); |
| break; |
| case "FY09": |
| activeTable.showColumn( 13 ); |
| break; |
| case "Hide Column" : |
| activeTable.hideColumn( colIndex ); |
| break; |
| default : |
| break; |
| } |
| } |
colIndex = GetRealCellIndex( activeTable, eventArgs.get_gridColumn().get_element());
I have a combo box that I populate with with searchig a db once the user has typed at least two characters. How do I make sure that the user actually selects one of the returned items and doesn't simply type a few characters and move on? I need the value in the control to be one of the returned items whether the user types it all the way out or selects an option after the LoadOnDemand. Is there a property I am not using correctly or a client side script approach?
<telerik:RadComboBox ID="cboAccounts" runat="server" Width="300" Font-Size="11px"
EnableLoadOnDemand="true" AllowCustomText="false" MarkFirstMatch="true" EnableTextSelection="true"
EmptyMessage="Search/Select an Account" IsCaseSensitive="false" EnableItemCaching="true"
LoadingMessage="Fetching matching items..." ShowDropDownOnTextboxClick="false"
Height="100" AutoPostBack="true" CausesValidation="false">
<ExpandAnimation Duration="200" />
<CollapseAnimation Duration="200" />
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="cboAccounts"
runat="server" ErrorMessage="*" CssClass="ErrorMsg"></asp:RequiredFieldValidator>
Private Sub cboAccounts_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles cboAccounts.ItemsRequested
If e.Text <> String.Empty And Len(e.Text) >= 2 Then
Dim dtbl As DataTable = SearchAccounts("", e.Text, Url.GetPath(), ActiveUser.UserID)
For Each row As DataRow In dtbl.Rows
Dim item As New RadComboBoxItem(row("account_name").ToString() & " (" & row("account_type").ToString() & ")", row("account_no").ToString())
cboAccounts.Items.Add(item)
Next
End If
End Sub
Private Function SearchAccounts(ByVal top As String, ByVal prefixText As String, ByVal path As String, ByVal user_id As String) As DataTable
Dim dvw As DataTable
With New VBDataLayer.SqlServer(conStr)
.AddParameter("@top", top)
.AddParameter("@prefixText", prefixText)
.AddParameter("@path", path)
.AddParameter("@user_id", user_id)
.AddParameter("@version", CStr(Session("version")))
dvw = .RunProc("wsp_web_Search_Accounts2", "Accounts").Tables(0)
End With
Return dvw
End Function
I have a stored procedure that accepts a parameter ("UserID") via a session variable, and returns specific data. The data in question comprises of multiple columns containing branch number, and address. I have tested this query, and it performs correctly, returning the necessary data. However, when testing the page (and combo box), the combo box does not list the data, but rather has an item in it that says "System.Data.DataRowView" - and nothing else. This has me a little lost, as I am not certain why it is doing this. Here's the requisite code:
| 'This is the code behind code for the page_load event; |
| Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
| Dim conn As New SqlClient.SqlConnection |
| Dim cmd As New SqlClient.SqlCommand |
| MemUser = Membership.GetUser() |
| UserID = MemUser.UserName.ToString() |
| Session("UserID") = UserID & "@tscgrpsolutions.com" |
| End Sub |
| <!-- Here's the combo box & datasource--> |
| <telerik:RadComboBox ID="ddlSelectStore" runat="server" Skin="Black" Width="300px" |
| DataSourceID="sqlStoreSelect"> |
| </telerik:RadComboBox> |
| <!-- Data Connections--> |
| <asp:SqlDataSource ID="SqlDataSource1" runat="server" |
| ConnectionString="<%$ ConnectionStrings:xxxxxxxxxx%>" |
| SelectCommand="StoreSelectCommand" SelectCommandType="StoredProcedure"> |
| <SelectParameters> |
| <asp:SessionParameter DefaultValue="xxxxxxxxxxxxxx" |
| Name="RepName" SessionField="UserID" Type="String" /> |
| </SelectParameters> |
| </asp:SqlDataSource> |