Hi everyone,
Any and all assistance here is greatly appreciated!
I'm trying to implement a Listbox Transfer scenario - allowing typical moving items from one list box to another.
The transferring of items back and forth is working fine.
The part that isn't working is getting changes to update a SQL database.
But once something is moved, the underlying dataTable doesn't have any changes.
What am I missing in order to acknowledge changes in the Selected dataTable?
Thank you in advance.
Here's the listboxes defined:
<telerik:RadListBox ID="RadListBox1" CssClass="RadListBoxAvailable" runat="server" SelectionMode="Multiple" AllowTransfer="True" TransferToID="RadListBox2" AllowTransferOnDoubleClick="True" EnableDragAndDrop="True" OnTransferred="RadListBox1_Transferred" AutoPostBackOnTransfer="True" Sort="Ascending"></telerik:RadListBox> <telerik:RadListBox ID="RadListBox2" CssClass="RadListBoxSelected" runat="server" SelectionMode="Multiple" AllowTransferOnDoubleClick="True" EnableDragAndDrop="True" AutoPostBackOnTransfer="True" Sort="Ascending"></telerik:RadListBox>And here's the c#:
using System;using System.Configuration;using System.Data;using System.Data.SqlClient;using Telerik.Web.UI;public partial class testX : System.Web.UI.Page{ public static DataTable dtSelected; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadAvailable(); LoadSelected(); } } private void LoadAvailable() { string query = "select personId, person from peopleList"; RadListBox1.DataSource = GetDataTable(query); RadListBox1.DataSortField = "person"; RadListBox1.DataTextField = "person"; RadListBox1.DataValueField = "personId"; RadListBox1.DataBind(); } private void LoadSelected() { string query = "select personId, person from peopleChosen"; dtSelected = GetDataTable(query); RadListBox2.DataSource = dtSelected; RadListBox2.DataTextField = "person"; RadListBox2.DataSortField = "person"; RadListBox2.DataValueField = "personId"; RadListBox2.DataBind(); } private DataTable GetDataTable(string query) { String ConnString = ConfigurationManager.ConnectionStrings["wareConnectionString"].ConnectionString; SqlConnection conn = new SqlConnection(ConnString); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = new SqlCommand(query, conn); DataTable myDataTable = new DataTable(); conn.Open(); try {adapter.Fill(myDataTable);} finally {conn.Close();} return myDataTable; } protected void RadListBox1_Transferred(object sender, Telerik.Web.UI.RadListBoxTransferredEventArgs e) { if (DataTableHasChanges(dtSelected)) { LabelEditStatus.Text = "Changes not Saved"; } else { LabelEditStatus.Text = ""; } } public bool DataTableHasChanges(DataTable dataTable) { return (dataTable != null) ? dataTable.GetChanges() != null : false; } }
The following is mentioned in one of the web pages in the telerik site. We are using telerik in our application and the project started nearly 3 years ago. So, is there a way I can ensure I am using the latest RadSplitter which had this performance improvement?
RadSplitter
<GroupingSettings ShowUnGroupButton="true" CaseSensitive="false" />
<ClientSettings AllowDragToGroup="true" AllowColumnsReorder="true">
<Selecting AllowRowSelect="true" />
<Resizing AllowColumnResize="true" EnableRealTimeResize="true" ResizeGridOnColumnResize="true" />
<Scrolling SaveScrollPosition="false" AllowScroll="false" />
<ClientEvents OnPopUpShowing="PopUpShowing" />
</ClientSettings><telerik:RadComboBox ID="RadComboBoxStringInLookupValue" Runat="server" Width="325px" EnableTextSelection="False" DropDownWidth="325px" HighlightTemplatedItems="True" Visible="true" CloseDropDownOnBlur="False" > <ItemTemplate> <ul> <li class="col1"> <telerik:RadListBox ID="RadListBoxSource" runat="server" Height="125px" DataSourceID="ObjectDataSourceLookUpValues" DataTextField="Descr" DataValueField="Code" AllowTransfer="true" TransferToID="RadListBoxDestination" AllowTransferOnDoubleClick="True" SelectionMode="Multiple" Enabled="True" OnClientSelectedIndexChanging="SetDropDownToOpen" OnClientSelectedIndexChanged="SetCanvasChanged" ondatabound="OnDataBound" onitemdatabound="OnItemsDataBound" > <ButtonSettings ReorderButtons="Common"></ButtonSettings> </telerik:RadListBox> </li> <li class="col2"> <telerik:RadListBox ID="RadListBoxDestination" runat="server" Height="125px" SelectionMode="Multiple"> <ButtonSettings ReorderButtons="Common"></ButtonSettings> </telerik:RadListBox> </li> </ul> </ItemTemplate> <Items> <telerik:RadComboBoxItem Text="" /> </Items> </telerik:RadComboBox> <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" AllowedFileExtensions=".pdf" OnFileUploaded="RadAsyncUpload1_FileUploaded" MaxFileInputsCount="1" AllowedMimeTypes="application/pdf" Width="300px" InputSize="48" MaxFileSize="20600" EnableFileInputSkinning="False" Skin="Vista" ChunkSize="0" TargetFolder="c:/TESTUPLOADS"> </telerik:RadAsyncUpload> </td></tr><tr> <td><asp:CheckBox ID="chkLibrary" runat="server" Text="Add To Library"/> </td></tr> <tr> <td> <table cellpadding="2" cellspacing="2" width="100%" border="0"> <tr> <td style="width:100%;"> <asp:CustomValidator ID="Customvalidator1" runat="server" Display="Dynamic" ClientValidationFunction="validateRadAsyncUpload1"> <span style="FONT-SIZE: 11px;">Invalid file type.</span> </asp:CustomValidator> </td> <td> <asp:Button ID="buttonSubmit" runat="server" CssClass="RadUploadButton" Text="Import" style="width:95px"/> </td> <td> <asp:Button ID="ctlCancelButton" runat="server" OnClientClick="Cancel_Clicked();return false;" Text="Cancel" style="width:95px"/> </td> </tr>
Protected Sub RadAsyncUpload1_FileUploaded(sender As Object, e As Telerik.Web.UI.FileUploadedEventArgs) Handles RadAsyncUpload1.FileUploaded
Dim targetFolder As String = RadAsyncUpload1.TargetFolder
Response.Write(Server.MapPath(targetFolder & "/" & e.File.FileName))
End Sub