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

Edit field in list box

2 Answers 30 Views
This is a migrated thread and some comments may be shown as answers.
Najid Hanif
Top achievements
Rank 2
Najid Hanif asked on 10 Nov 2011, 11:09 PM
I have an radtext box as a field in a list box. I am not sure how I go about getting that field to update. After the user fills in the field, what could I use to trigger the update?

See screen show of what it looks like

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReviewFormProjects.aspx.cs" Inherits="Helpers.RFP" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<head id="Head1" runat="server">
    <link href="ReviewFormProjects.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
     /* The default display: inline needs to be overrided to resize the container to hold with the content */
     div.RadListBox .rlbTemplate
         display: inline-block;
<body class="BODY">
    <form runat="server" id="mainForm" method="post">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1">
        <div class="example-panel">
            <div class="order-panel">
                <label class="product-list">
                    Avalible Projects to choose</label>
                <label class="detail">
                    Associate with application</label>
                   <%-- OnTransferred="RadListBox1_Transferred"--%>
                 <%--  TransferMode="Copy"--%>
                <telerik:RadListBox ID="RadListBox1" runat="server" AllowTransfer="True" AutoPostBackOnTransfer="True" DataValueField="ProjectNameID"
                    Height="200px" SelectionMode="Multiple" AllowTransferDuplicates="true"
                    TransferToID="RadListBox2" Width="215px" DataSourceID="ProjectNamesList" DataKeyField="ProjectNameID" DataTextField="ProjectName" DataSortField="ProjectName" OnTransferred="RadListBox1_Transferred" TransferMode="Copy">
                    <ButtonSettings ShowTransferAll="false" VerticalAlign="Middle" />
                <telerik:RadListBox runat="server" ID="RadListBox2" Height="200px" Width="270px" AllowTransfer="True"
                    SelectionMode="Multiple" DataSourceID="ProjectUpdates" DataKeyField="ProjectNameID" DataTextField="ProjectName" DataValueField="ProjectNameID"  AllowDelete="True"
   AllowAutomaticUpdates="true" AllowTransferDuplicates="true">
                        <span class="detail-title">
                        <ul class="details">
                                <%--<label> <%# DataBinder.Eval(Container, "Text")%>:</label>--%>
                                <telerik:RadTextBox runat="server" ID="ProjectNameIDTextBox" Width="150px" Text='<%# Bind("ProjectID") %>' Label='<%# Bind("ProjectName") %>'/>
    <asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:PreQual_DEV_ConnectionString %>"
        ID="ProjectNamesList" runat="server" SelectCommand="SELECT ProjectNameID, ProjectName FROM PublicFormProjectNames">
   <asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:PreQual_DEV_ConnectionString %>"
        ID="ProjectUpdates" runat="server"
        SelectCommand="SELECT     PN.ProjectName, P.ID, P.ProjectNameID, P.ProjectID, P.FormID
FROM         PublicFormProjectNames AS PN INNER JOIN
                      PublicFormProjects AS P ON PN.ProjectNameID = P.ProjectNameID WHERE FormID = 1"
        DeleteCommand="DELETE FROM [PublicFormProjects] WHERE [ID] = @ID"
        InsertCommand="INSERT INTO [PublicFormProjects] ([FormID], [ProjectNameID], [ProjectID]) VALUES (@FormID, @ProjectNameID, @ProjectID)"
        UpdateCommand="UPDATE [PublicFormProjects] SET [ProjectNameID] = @ProjectNameID, [ProjectID] = @ProjectID WHERE [ID] = @ID"
            <asp:ControlParameter Name="ProjectNameID" Type="String" controlid="ProjectNameIDTextBox" />
            <asp:Parameter Name="ProjectID" Type="Int32" />
            <asp:Parameter Name="ID" Type="Int32" />
            <asp:Parameter Name="ProjectID" Type="String"/>
            <asp:ControlParameter Name="ProjectNameID" Type="Int32" controlid="RadListBox1" propertyname="SelectedValue" />
            <asp:Parameter Name="FormID" Type="Int32" DefaultValue="1" />

2 Answers, 1 is accepted

Sort by
Najid Hanif
Top achievements
Rank 2
answered on 15 Nov 2011, 03:23 PM

Peter Filipov
Telerik team
answered on 15 Nov 2011, 03:55 PM
Hello Najid,

Thank you for contacting Telerik Support.

In general the RadListBox does not support automatic database update when templates are used.
In your case you can use TextChanged event of the RadTextBox control (make sure that AutoPostBack is set  to true). In the event  handler function you can update your database.

I will be glad to assist you further.

Best wishes,
Peter Filipov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Asked by
Najid Hanif
Top achievements
Rank 2
Answers by
Najid Hanif
Top achievements
Rank 2
Peter Filipov
Telerik team
Share this question