Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
83 views

Hello everybody i am a little bit stuck and unable to figure aout the problem i am having.... my buttun in bellow form doesn't do anything, this example is guided from http://demos.telerik.com/aspnet-ajax/editor/examples/saveindatabase/defaultcs.aspx only differnce is that i use sql database, here is my example:

this is cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Telerik.Web.UI;


public partial class editVijesti_vijesti : System.Web.UI.Page
{
   
protected void Page_Load(object sender, EventArgs e)
   
{
       
if (!Page.IsPostBack)
       
{
           
ReadAllRecords();
       
}
   
}

   
   
public void btnSpremi_Click(object sender, EventArgs e)
   
{
       
SqlConnection connection = CreateConnection();
       
SqlCommand command= null;

       
if (uredeneVijesti.Value != string.Empty)
       
{
            command
= new SqlCommand("UPDATE Vijesti SET Datum = Now(), TijeloVijesti = @content WHERE vijestiID= @nid", connection);
            command
.Parameters.AddWithValue("content", EditorVijesti.Content);
            command
.Parameters.AddWithValue("nid", Convert.ToInt32(uredeneVijesti.Value));
       
}

       
else
       
{
            command
= new SqlCommand("INSERT INTO Vijesti (Datum, TijeloVijesti) VALUES (Now(), @content)", connection);
            command
.Parameters.AddWithValue("content", EditorVijesti.Content);
           
       
}
       
try
       
{
            command
.ExecuteNonQuery();
       
}
       
catch (Exception)
       
{ }
        connection
.Close();
       
this.Response.Redirect(this.Request.Url.PathAndQuery);

   
}


   
protected SqlConnection CreateConnection()
   
{
       
SqlConnection connection = new SqlConnection();
        connection
.ConnectionString = "Data Source=mssql3.mojsite.com,1555;Initial Catalog=iskratrade_hai;Persist Security Info=True;User ID=iskratrade_hai;Password=091011br"; connection.Open();
       
return connection;
   
}

   
   
protected void gridVijesti_ItemCommand(object sender, DataGridCommandEventArgs args)
   
{
       
SqlConnection connection = CreateConnection();
       
if (args.CommandName == "Delete")
       
{
           
SqlCommand com = new SqlCommand("DELETE FROM  Vijesti WHERE vijestiID =@nid", connection);
            com
.Parameters.AddWithValue("nid", args.Item.Cells[0].Text);
            com
.ExecuteNonQuery();
            connection
.Close();
       
}
       
else if (args.CommandName == "Edit")
       
{
           
SqlCommand command = new SqlCommand("SELECT TijeloVijesti FROM Vijesti WHERE vijestiID= @nid", connection);
            command
.Parameters.AddWithValue("nid", args.Item.Cells[0].Text);
           
SqlDataReader record = command.ExecuteReader();
           
if (record.Read())
           
{
               
EditorVijesti.Content = record.GetString(0);
                uredeneVijesti
.Value = args.Item.Cells[0].Text;
           
}
           
else
           
{
               
EditorVijesti.Content = "";
                uredeneVijesti
.Value = "";
           
}
            record
.Close();

       
}
        connection
.Close();
       
ReadAllRecords();
   
}
   
private void ReadAllRecords()
   
{
       
SqlConnection connection = CreateConnection();
       
SqlCommand command2 = new SqlCommand("SELECT vijestiID, Datum, TijeloVijesti FROM Vijesti", connection);
        gridVijesti
.DataSource = command2.ExecuteReader();
        gridVijesti
.DataBind();
        connection
.Close();
   
}
 
}
 
and this is aspx page:
 
<asp:ScriptManager ID="scriptmanager" runat="server"/>
           
       
       
<div>
         
<input type="hidden" name="uredeneVijesti" runat="server" id="uredeneVijesti" />

   
<telerik:RadEditor ID="EditorVijesti" runat="server" SkinID="DefaultSetOfTools"
            height
="500px" Width="800px">
           
<Modules>
             
<telerik:EditorModule Name="RadEditorStatistics" Visible="false" Enabled="true" />
               
<telerik:EditorModule Name="RadEditorDomInspector" Visible="false" Enabled="true" />
                           
<telerik:EditorModule Name="RadEditorNodeInspector" Visible="false" Enabled="true" />
                           
<telerik:EditorModule Name="RadEditorHtmlInspector" Visible="false" Enabled="true" />
           
</Modules>
     

    <ImageManager ViewPaths="~/
editVijesti" UploadPaths="~/editVijesti/slike/novo" DeletePaths="~/editVijesti/slike/obrisano" />
    <FlashManager DeletePaths="
editVijesti/slike/obrisano" UploadPaths="~/editVijesti/slike/novo" ViewPaths="~/editVijesti/slike" />
    <DocumentManager DeletePaths="
editVijesti/slike/obrisano" UploadPaths="~/editVijesti/slike/novo" ViewPaths="~/editVijesti/slike" />
    <MediaManager DeletePaths="
editVijesti/slike/obrisano" UploadPaths="~/editVijesti/slike/novo" ViewPaths="~/editVijesti/slike" />
    <TemplateManager DeletePaths="
editVijesti/slike/obrisano" UploadPaths="~/editVijesti/slike/novo" ViewPaths="~/editVijesti/slike" />
        </telerik:RadEditor>

        <br />
        <asp:Button ID="
btnSpremi" runat="server" Text="Spremi u bazu" OnClick="btnSpremi_Click" />
        <br />
        <br />
       <asp:DataGrid ID="
gridVijesti" runat="server" BorderWidth="1px" CellPadding="3"
            AutoGenerateColumns="
False" Width="620px"
            OnItemCommand="
gridVijesti_ItemCommand">
         <HeaderStyle Font-Names="
Verdana" ForeColor="Black" BackColor="#d3e5fa" />
           
<Columns>
             
               
<asp:BoundColumn DataField="vijestiID"></asp:BoundColumn>
               
<asp:ButtonColumn CommandName="Delete" ButtonType="LinkButton"
                   
HeaderText="Obriši" Text="Delete"></asp:ButtonColumn>
               
<asp:ButtonColumn ButtonType="LinkButton" CommandName="Edit" HeaderText="Uredi" Text="Uredi"></asp:ButtonColumn>
               
<asp:BoundColumn DataField="Datum" HeaderText="Datum"></asp:BoundColumn>

             
<asp:BoundColumn DataField="TijeloVijesti" HeaderText="Tekst"></asp:BoundColumn>
             
           
</Columns>
       </
asp:DataGrid>

   
</div>



problem is with the button btnSpremi no insert to database, tables are set to Datum-- datetame (data type) , vijestiID----int -is identity incremenet seed, and TijeloVijesti --nvarchar(MAX) .. .. unable to insert to database read from databse is working good delete also but insert nothing... please if you can look at the code,.. regards

Rumen
Telerik team
 answered on 13 Sep 2011
1 answer
67 views
Pavlina
Telerik team
 answered on 13 Sep 2011
6 answers
87 views
Hi,

i want to disable checkbox of recursion in case user is editing indivisual appointment of recurrsive appointment. any idea to acheive that. if editing is for series checkbox needs to be enabled else disabled.


Thanks
Kevin
Top achievements
Rank 1
 answered on 13 Sep 2011
1 answer
282 views
Hi,

I'm using the RadCombox ItemsRequested to perform partial search....this feature works fine. However, during the update, the RadCombobox.text is already prepopulated. This causes the dropdown to be blank (view the error.jpg). Is there anyway to specify that once the user clicks on the RadCombox dropdown, the selected value disappears and the full dropdown list appears? 

 

 

//Populate the Area dropdown

 

 

 

protected void RadComboBoxArea_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)

 

{

 

 

RadComboBox comboBox = (RadComboBox)sender;

 

 

 

// Clear the default Item that has been re-created from ViewState at this point.

 

comboBox.Items.Clear();

 

 

 

BindingList<LookupArea> Area = WellVentDataLayer.GetAreas(e.Text);

 

 

 

foreach (LookupArea i in Area)

 

{

comboBox.Items.Add(

 

new RadComboBoxItem(i._AreaName.ToString(), i._ID.ToString()));

 

}

comboBox.DataBind();

}

Kalina
Telerik team
 answered on 13 Sep 2011
2 answers
76 views
We have upgraded the version of the RadEditor from 5.4.0.0 to 5.7.1.0.  Now we have two folders for configuration at the location Program Files\Common Files\Microsoft Shared\web server extensions\wpresources\RadEditorSharePoint. It creates confusion with the client.
Arun
Top achievements
Rank 1
 answered on 13 Sep 2011
6 answers
933 views
Hi

I am getting error " microsoft jscript runtime error 'undefined' is null or not an object" when i call clent script code from code behind in page load event. ( I shoul open the radwindow on page load).  Please see my code below.

ASPX Code
<%@ Page Language="C#" MasterPageFile="~/CMMasterPage.master" AutoEventWireup="true"
    CodeFile="ActualvsRequired.aspx.cs" Inherits="Reports_ActualvsRequired" Title="Untitled Page" %>
  
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Charting" TagPrefix="telerik" %>
<asp:Content ID="Content2" ContentPlaceHolderID="header" runat="Server">
    Resource Level
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <link href="../Styles/CrewMetric_StyleSheet.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
        //Sys.Application.remove_load(RadWindowOpen);
        //Sys.Application.add_load(RadWindowOpen);
        var oWnd;
  
        function RadWindowOpen() {
  
                if (oWnd != null) {
                    oWnd.close();
                }
                oWnd = radopen("GridDisplay.aspx", null); ///Getting error
                oWnd.setSize(200, 225);
                oWnd.moveTo(1090, 160);
                return false;
            }
    </script>
      
     
    <div id="divContentPage" class="subbody" runat="server">
        <div style="float: left; margin-left: 8px; margin-top: 10px;">
            <telerik:RadChart runat="Server" ID="RadChartAvR" Width="900px" Height="560" OnItemDataBound="RadChartAvR_ItemDataBound"
                OnBeforeLayout="RadChartAvR_BeforeLayout">
                <PlotArea>
                    <EmptySeriesMessage Visible="True">
                        <Appearance Visible="True">
                        </Appearance>
                    </EmptySeriesMessage>
                    <YAxis>
                        <AxisLabel Visible="true" TextBlock-Text="% of Actual Deviation from Requirement">
                            <Appearance Visible="True">
                            </Appearance>
                            <TextBlock Text="% of Actual Deviation from Requirement">
                            </TextBlock>
                        </AxisLabel>
                    </YAxis>
                </PlotArea>
                <ChartTitle Visible="true">
                      
                </ChartTitle>
            </telerik:RadChart>
        </div>
        <div style="clear: both">
        </div>
    </div>
    <div>
        <asp:HiddenField ID="hiddenCrewType" runat="server" />
    </div>
    <telerik:RadWindowManager ID="RadWindowManager2" runat="server" ReloadOnShow="false" Skin="Sunset" BackColor="DodgerBlue" EnableEmbeddedSkins="false"
        ShowContentDuringLoad="False" VisibleStatusbar="False"  InitialBehavior="None" Behaviors="Move" 
        Font-Names="Tahoma" VisibleOnPageLoad="false" Style="z-index: 8000;" EnableShadow="true"
        DestroyOnClose="True">
    </telerik:RadWindowManager>
</asp:Content>


CS Code:

ScriptManager

 

 

.RegisterStartupScript(this.Page, Page.GetType(), "test", "RadWindowOpen();", true);

 


Marin Bratanov
Telerik team
 answered on 13 Sep 2011
1 answer
187 views
Hi,

My RadGrid is all created programmatically in the page_init.  The data source is a DataTable.

The OnNeedDataSource seems fine (well, there is data!), but when I put in into edit mode to add a new row - add data and click on the tick - it does nothing.  The events aren't called.

The event handers are added in the method called by the page_init :

private void CreateForecastGrid()
{
.
.
.
.
.
             //Add the Notes column
                GridTemplateColumn notes = new GridTemplateColumn();
                RadGrid1.MasterTableView.Columns.Add(notes);
  
                notes.ItemTemplate = new NotesDataGridTemplate(ListItemType.Item, "lblNotes");
                notes.EditItemTemplate = new NotesDataGridTemplate(ListItemType.EditItem, "tbNotes");
                notes.HeaderText = "Notes";
                notes.UniqueName = "Notes";
                notes.SortExpression = "Notes";
  
                //Add the Discipline column
.
.
.
            //Add event handlers
            RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_OnNeedDataSource);
            RadGrid1.ItemUpdated += new GridUpdatedEventHandler(RadGrid1_ItemUpdated);
            RadGrid1.ItemInserted += new GridInsertedEventHandler(RadGrid1_ItemInserted);
            RadGrid1.ItemDataBound += new GridItemEventHandler(RadGrid1_OnItemDataBound);
            RadGrid1.DataBound += new EventHandler(RadGrid1_DataBound);
  
            //Add the grid to the view
            RadGridPlaceholder.Controls.Add(RadGrid1);
        }

What am I doing wrong?

Thanks
Weeble
Top achievements
Rank 1
 answered on 13 Sep 2011
2 answers
87 views
Hi everybody!
I have a problem about checkbox and radgrid. I want to tick in checkbox when I choose row select in radgrid. I used:
function setValues(d_diem_do) {         
           $find("<%= txtMA_DDO.ClientID %>").set_value(d_diem_do.MA_DDO);
           $find("<%= dtpNGAY_HLUC.ClientID %>").set_selectedDate(d_diem_do.NGAY_HLUC);
           $find("<%= chkCSPK.ClientID %>").checked = false;                 //Error here 
       }
My code: $find("<%= chkCSPK.ClientID %>").checked = false;  is not run.
Have you any idea? Thanks you very much!
Pham
Top achievements
Rank 1
 answered on 13 Sep 2011
6 answers
304 views
Hi
I have 2 tab control in my page. On load of the page,  i am opening a radwindow. Please see my code below.
var oWnd;
function pageLoad() {
    if (oWnd != null) {
        oWnd.close();
    }
    oWnd = radopen("GridDisplay.aspx", null);
    oWnd.setSize(200, 225);
    oWnd.moveTo(1090, 160);
    return false;
}
My requirement is, i have to set the window size and position based on the tab selection. For that i have done below code. I have created one hidden control.I assigned value for that. I was trying to take that value in client side, it was throwing error saying that cannot used content control <%# %>. I replaced with # to =. At that time it is not throwing error but it is not returning the value.
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
            <script type="text/javascript">
               var obj = document.getElementById("<%#hiddenCrewType.ClientID%>")
               alert(obj);
                alert(1);            
            </script>
    </telerik:RadScriptBlock>
So now i decided to move my code to server side. Can you please suggest how to set the window size and position for the rad window in server side?
Marin Bratanov
Telerik team
 answered on 13 Sep 2011
4 answers
306 views
Hi,

I have a RadComboBoxData object with all the data items. How can use it to populate RadComboBox?
Kalina
Telerik team
 answered on 13 Sep 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?