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

Edit field in list box

2 Answers 30 Views
ListBox
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" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<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;
     }
    </style>
    <title>test</title>
</head>
<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>
                <telerik:RadListBox runat="server" ID="RadListBox2" Height="200px" Width="270px" AllowTransfer="True"
                    SelectionMode="Multiple" DataSourceID="ProjectUpdates" DataKeyField="ProjectNameID" DataTextField="ProjectName" DataValueField="ProjectNameID"  AllowDelete="True"
   AutoPostBackOnDelete="true"
   AllowAutomaticUpdates="true" AllowTransferDuplicates="true">
                    <ItemTemplate>
                        <span class="detail-title">
                        <ul class="details">
                            <li>
                                <%--<label> <%# DataBinder.Eval(Container, "Text")%>:</label>--%>
                                <telerik:RadTextBox runat="server" ID="ProjectNameIDTextBox" Width="150px" Text='<%# Bind("ProjectID") %>' Label='<%# Bind("ProjectName") %>'/>
                            </li>
                        </ul>
                    </ItemTemplate>
 
                </telerik:RadListBox>
            </div>
        </div>
    </telerik:RadAjaxPanel>
 
    <asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:PreQual_DEV_ConnectionString %>"
        ID="ProjectNamesList" runat="server" SelectCommand="SELECT ProjectNameID, ProjectName FROM PublicFormProjectNames">
    </asp:SqlDataSource>
 
   <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"
        >
       <UpdateParameters>
            <asp:ControlParameter Name="ProjectNameID" Type="String" controlid="ProjectNameIDTextBox" />
            <asp:Parameter Name="ProjectID" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="ProjectID" Type="String"/>
            <asp:ControlParameter Name="ProjectNameID" Type="Int32" controlid="RadListBox1" propertyname="SelectedValue" />
            <asp:Parameter Name="FormID" Type="Int32" DefaultValue="1" />
        </InsertParameters>
    </asp:SqlDataSource>
 
    </form>
</body>
</html>

2 Answers, 1 is accepted

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

Thanks
0
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
Tags
ListBox
Asked by
Najid Hanif
Top achievements
Rank 2
Answers by
Najid Hanif
Top achievements
Rank 2
Peter Filipov
Telerik team
Share this question
or