using
System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Telerik.Web.UI;
using WebApplicationProtoypeZenith;
using Telerik.QuickStart;
namespace WebApplicationProtoypeZenith
{
public partial class Admin : System.Web.UI.Page
{
private static DataTable GetDataTable(string queryString)
{
String ConnString = ConfigurationManager.ConnectionStrings["SysnetDenmarkConnectionString"].ConnectionString;
SqlConnection MySqlConnection = new SqlConnection(ConnString);
SqlDataAdapter MySqlDataAdapter = new SqlDataAdapter();
MySqlDataAdapter.SelectCommand = new SqlCommand(queryString, MySqlConnection);
DataTable myDataTable = new DataTable();
MySqlConnection.Open();
try
{
MySqlDataAdapter.Fill(myDataTable);
}
finally
{
MySqlConnection.Close();
}
return myDataTable;
}
private DataTable Projects
{
get
{
object obj = this.Session["Project"];
if ((!(obj == null)))
{
return ((DataTable)(obj));
}
DataTable myDataTable = new DataTable();
myDataTable = GetDataTable("SELECT * FROM Project");
this.Session["Project"] = myDataTable;
return myDataTable;
}
}
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
this.RadGrid1.DataSource = this.Projects;
this.Projects.PrimaryKey = new DataColumn[] { this.Projects.Columns["ProjectId"] };
}
protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
//Create new row in the DataSource
DataRow newRow = this.Projects.NewRow();
//Insert new values
Hashtable newValues = new Hashtable();
newValues["ProjectName"] = (userControl.FindControl("RadTextBoxProjectName") as RadTextBox).Text;
newValues["ProjectResume"] = (userControl.FindControl("RadEditor1") as RadEditor).Content;
newValues["ProjectStart"] = (userControl.FindControl("RadDatePickerProjectStart") as RadDatePicker).SelectedDate;
newValues["ProjectEnd"] = (userControl.FindControl("RadDatePickerProjectEnd") as RadDatePicker).SelectedDate;
newValues["Responsible"] = (userControl.FindControl("RadTextBoxResponsible") as RadTextBox).Text;
newValues["OrderdBy"] = (userControl.FindControl("RadTextBoxOrderdBy") as RadTextBox).Text;
newValues["Contact"] = (userControl.FindControl("RadTextBoxContact") as RadTextBox).Text;
//make sure that unique primary key value is generated for the inserted row
newValues["ProjectId"] = (int)this.Projects.Rows[this.Projects.Rows.Count - 1]["ProjectId"] + 1;
try
{
foreach (DictionaryEntry entry in newValues)
{
newRow[(string)entry.Key] = entry.Value;
}
this.Projects.Rows.Add(newRow);
this.Projects.AcceptChanges();
}
catch (SqlException ecx)
{
RadGrid1.Controls.Add(new LiteralControl("Unable to update/insert Projects. Reason: " + ecx.StackTrace));
}
catch (Exception ex)
{
RadGrid1.Controls.Add(new LiteralControl("Unable to update/insert Projects. Reason: " + ex.Message));
e.Canceled = true;
}
}
}
For some reason i can not get the default text to display more than one word. if there is a space in the call to radprompt only the characters before the space are shown in the textbox. I am using the latest ajax control and the default radprompt.
radprompt('Type:', promptEditToolBarType, 330, 100, null, 'Edit Toolbar Name', 'My Toolbar');
this displays only 'My' in the textbox.
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
I have also added the files "Telerik.Web.UI.dll" and "Telerik.Web.UI.XML" to the bin map. In the code behind i find the classes included in Telerik.Web.UI but in the aspx-file i cannot find the controls such as ColorPickerItem ect. (for example:
<telerik:RadColorPicker runat="server" ID="RadColorPicker2" Columns="5" Width="210">
This row gives the error message in design mode "Unrecognized tag prefix or device filter 'telerik'."
When i try the application i get the errormessage: "Unknown server tag 'telerik:RadColorPicker'" Other Server tags works find in this file.
Regards
/Per