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

Insert new record question

3 Answers 51 Views
Input
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 13 Apr 2011, 05:47 PM
Hi,

I am not able to get the ID from the dropdown to do the insert of the new record based on that selected item from the that dropdown. 
So when I click the "Add file" no record is being saved to the database.

thanks



<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
  <telerik:RadFormDecorator 
                        ID="RadFormDecorator1" Runat="server" Skin="Windows7" DecoratedControls="Textbox" />
    <div style="padding-left:20px">
    <table width="90%" border="0" cellpadding="5" style="text-align:left">
         
        <tr>
            
            <td align="left">  <div style="font-size: 14pt; font-weight: bold;">
                    Add New Media
                </div>
            </td>  <td align="right" >
                <img src="../images/arrow_back.png" align="absmiddle" /> <asp:LinkButton ID="btnAddMedia" Font-Bold="false"   CausesValidation="false" runat="server" Text="Back to Listings" />
            </td>
        </tr>
         <tr>
            <td><div runat="server" id="successaddmsg" visible="false">
                <img src="../images/accept.png" align="absmiddle" /> 
                <asp:Label ID="Label1" runat="server" ForeColor="green"  Font-Bold="true" Font-Size="12px" Text="Media item was successfully added." />
            </div>
            </td>
            <td>
                <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="validateRadUpload"
                    ErrorMessage="Please select at least one valid media file" fileOnServerValidate="CustomValidator1_ServerValidate" />
            </td>
        </tr>
        <tr>
            <td>
                Categroy:
            </td>
            <td>
                <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource2"
                    AppendDataBoundItems="true" DataTextField="Category" DataValueField="CatId" Skin="Windows7">
                    <Items>
                        <telerik:RadComboBoxItem />
                    </Items>
                </telerik:RadComboBox>
            </td>
        </tr>
        <tr>
            <td>
                Media File:
            </td>
            <td>
                <telerik:RadUpload ID="RadUpload1" runat="server" ControlObjectsVisibility="None"
                    Skin="Office2007">
                </telerik:RadUpload>
            </td>
        </tr>
        <tr>
            <td>
                Title:
            </td>
            <td>
                <asp:TextBox ID="txtTitle" Width="321px" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                Comments:
            </td>
            <td>
                <asp:TextBox ID="txtDesc" Width="321px" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:CheckBox ID="chkShow" Checked="true" runat="server" Text="Make it available on User's Download Page." />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <br />
                <br />
                <asp:Button ID="btnAdd" runat="server" Text="Add file" />
            </td>
        </tr>
    </table>
    </div>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:MUNTERSJMmlConnectionString %>"
        SelectCommand="SELECT MediaCategories.CatId, MediaCategories.CatName AS Category FROM MediaCategories ORDER BY CatName ">
    </asp:SqlDataSource>
    <%--
      Upload Large File Setting Requirements:
      Open the file C:\Windows\System32\inetsrv\config\applicationHost.config and find the line:    
<section name="requestFiltering" overrideModeDefault="Deny" />
  
Set the overrideModeDefault property to Allow. So now the line should look like:
<section name="requestFiltering" overrideModeDefault="Allow" />
    --%>
</asp:Content>

3 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 19 Apr 2011, 01:33 PM
Hi Nick,

As far as I understand you are trying to obtain the SelectedValue in RadComboBox control at server-side in order to use it to update a database.
You can get the RadComboBox SelectedValue easily by handling the ASP.NET Button Click event in this way:
<telerik:RadComboBox ID="RadComboBox1"
runat="server"
    DataSourceID="SqlDataSource2"
    AppendDataBoundItems="true"
    DataTextField="CategoryName"
    DataValueField="CategoryID"
    Skin="Windows7">
    <Items>
        <telerik:RadComboBoxItem />
    </Items>
</telerik:RadComboBox>
<asp:Button ID="btnAdd" runat="server"
    Text="Add file"
    OnClick="btnAdd_Click" />

protected  void btnAdd_Click(object sender, EventArgs e)
{
    string selectedValue = this.RadComboBox1.SelectedItem.Value;
}

I used the RadComboBox definition that you have posted here to make a sample - please find it attached.

If the issue persists - could you please provide us more details about your implementation?

Greetings,
Kalina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Nick
Top achievements
Rank 1
answered on 20 Apr 2011, 07:44 PM
Hi,

Thank you for your response.  I do get the sample code to capture the Selected value in YOUR example and everything works fine. but your first line of code is as follows:

<%

 

@ page title="" language="VB" masterpagefile="~/_admin/MasterPageAdmin.master" autoeventwireup="true"  CodeFile="SelectedValue5.aspx.cs"  Inherits="SelectedValue5" %>

 




My Add_Media.aspx file begins with a line of code as follows (which already had "Inherits" references:

<%

 

@ page title="" language="VB" masterpagefile="~/_admin/MasterPageAdmin.master" autoeventwireup="true" inherits="_admin_Add_Media, App_Web_wegxudrb" %>

 

 

I get an error message whenever I try to add 

 

  CodeFile="Add_Media.aspx.vb"  Inherits="Add_Media"
I get this error:

The 'inherits' attribute cannot contain spaces

How can I add a reference to the code behind in my first line of code to work
my 2 files are Add_Media.aspx   and Add_Media.aspx.vb

 

 

0
Helen
Telerik team
answered on 26 Apr 2011, 02:28 PM
Hi Nick,

Could you please try the following:

<%@ page title="" language="VB" masterpagefile="~/_admin/MasterPageAdmin.master" autoeventwireup="true"  CodeFile="Add_Media.aspx.vb"  Inherits="_admin_Add_Media" %>


Regards,
Helen
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Input
Asked by
Nick
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Nick
Top achievements
Rank 1
Helen
Telerik team
Share this question
or