Unable to insert records in the row :
Error message - {"Unable to cast object of type 'Telerik.Web.UI.GridCommandItem' to type 'Telerik.Web.UI.GridEditFormInsertItem'."}
Am I missing something ??
| protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
| { |
| GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item; |
| string Activity = (insertedItem["Activity"].Controls[0] as TextBox).Text; |
| string Status = (insertedItem["Status"].Controls[0] as TextBox).Text; |
| string Comments = (insertedItem["Comments"].Controls[0] as TextBox).Text; |
| try |
| { |
| string Query = null; |
| Query = "INSERT into SheduleActivityDetails(Activity,Status,Comments) values('" + Activity + "','" + Status + "','" + Comments + "')"; |
| objDataLayer.ExecuteNonQuery(Query); |
| RebindRadGrid(); |
| } |
| catch (Exception ex) |
| { |
| RadGrid1.Controls.Add(new LiteralControl("Unable to insert Activity. Reason: " + ex.Message)); |
| e.Canceled = true; |
| } |
| <telerik:RadGrid ID="RadGrid1" runat="server" |
| Width="600px" AllowMultiRowSelection="false" AllowMultiRowEdit="false" AllowAutomaticInserts="false" |
| AllowAutomaticUpdates="false" AllowPaging="true" ShowStatusBar="true" AutoGenerateEditColumn="false" |
| EnableAJAX="true" OnNeedDataSource="RadGrid1_NeedDataSource" |
| OnInsertCommand="RadGrid1_InsertCommand" OnUpdateCommand="RadGrid1_UpdateCommand" |
| ShowFooter="True" OnItemCreated="RadGrid1_ItemCreated" Skin="Office2007"> |
| <ClientSettings> |
| <Selecting AllowRowSelect="true" EnableDragToSelectRows="true" /> |
| </ClientSettings> |
| <MasterTableView CommandItemDisplay="Top" DataKeyNames="Id" EditMode="InPlace" AllowAutomaticInserts="False" AutoGenerateColumns="false" Width="100%"> |
| <Columns> |
| <telerik:GridClientSelectColumn HeaderStyle-Width="40px" /> |
| <telerik:GridBoundColumn DataField="Id" Visible="true" HeaderText="Id" |
| UniqueName="Id" ReadOnly="True"> |
| </telerik:GridBoundColumn> |
| <%--<telerik:GridBoundColumn DataField="Activity Id" HeaderText="ID" ReadOnly="True" |
| SortExpression="ActivityId" UniqueName="Activity ID" Visible="false"> |
| <HeaderStyle Width="20px" ForeColor="Silver" /> |
| <ItemStyle ForeColor="Silver" /> |
| </telerik:GridBoundColumn>--%> |
| <telerik:GridBoundColumn DataField="Activity" HeaderText="Activity" SortExpression="Activity" |
| UniqueName="Activity"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Status" HeaderText="Status" SortExpression="Status" |
| UniqueName="Status" Visible="true" EditFormColumnIndex="1"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Comments" HeaderText="Comments" SortExpression="Comments" |
| UniqueName="Comments" Visible="true" EditFormColumnIndex="1"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <CommandItemTemplate> |
| <div style="padding: 10px 0px;"> |
| <asp:LinkButton Style="vertical-align: bottom" ID="btnEditSelected" runat="server" |
| CommandName="EditSelected" CausesValidation="false" Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="=../../Images/Edit.gif" /> Edit Selected Activity</asp:LinkButton> |
| <asp:LinkButton ID="LinkButton1" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="=../../Images/Update.gif" /> Update Activity</asp:LinkButton> |
| <asp:LinkButton ID="LinkButton2" runat="server" CommandName="CancelAll" CausesValidation="false" |
| Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="=../../Images/edit.png" /> Cancel editing</asp:LinkButton> |
| <asp:LinkButton ID="LinkButton3" runat="server" CommandName="InitInsert" Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="=../../Images/AddRecord.gif" /> Add new Activity</asp:LinkButton> |
| <asp:LinkButton ID="LinkButton4" runat="server" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="=../../Images/Insert.gif" /> Add this Activity</asp:LinkButton> |
| |
| <asp:LinkButton ID="LinkButton5" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="=../../Images/Refresh.gif"/> Refresh Activities</asp:LinkButton> |
| </div> |
| </CommandItemTemplate> |
| <EditFormSettings ColumnNumber="2" CaptionFormatString="Edit properties of Activity with Id {0}" |
| CaptionDataField="ActivityId"> |
| <FormTableItemStyle Wrap="False"></FormTableItemStyle> |
| <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> |
| <FormMainTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="5" BackColor="White" |
| Width="100%"/> |
| <FormTableStyle CellSpacing="0" CellPadding="2" CssClass="module" Height="110px" |
| BackColor="White"/> |
| <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> |
| <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record" |
| UniqueName="EditCommandColumn1" CancelText="Cancel edit"> |
| </EditColumn> |
| <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> |
| </EditFormSettings> |
| </MasterTableView> |
| </telerik:RadGrid> |
<
div class="headingbar">
<table style="width:100%;height:100%" cellpadding="0" cellspacing="0">
<tr>
<td>Some stuff here</td>
</tr>
</table>
</div>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
<div class="footer">
<table style="width:100%;height:100%" cellpadding="0" cellspacing="0">
<tr>
<td>Some stuff here</td>
</tr>
</table>
</div>
On the actual page, I have insert a splitter with two Vertical Panes in ContentPlaceHolder. I want the splitter to fill the remaining screen and resize with the window, showing scrollbar depending on the content. Is there a way to tell the splitter to set height to 100% of the remaining white space (or 100% - hieght of other items on the page).
Thanks in advance.
- Adam
Protected
Sub RadDock1_DockPositionChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.DockPositionChangedEventArgs) Handles RadDock1.DockPositionChanged, RadDock2.DockPositionChanged, RadDock3.DockPositionChanged
Dim mpContentPlaceHolder As ContentPlaceHolder = CType(Master.FindControl("ContentPlaceHolder3"), ContentPlaceHolder)
Dim i As Int32
Dim iDockTo, iDockFrom As Int32
Dim MyDock As Telerik.Web.UI.RadDock
Dim MyDockZone As Telerik.Web.UI.RadDockZone
iDockFrom = CalcDockNumber(sender.DockZoneID)
iDockTo = CalcDockNumber(e.DockZoneID)
If iDockFrom = iDockTo Then Exit Sub
MyDock = CType(mpContentPlaceHolder.FindControl("RadDock" & iDockTo), Telerik.Web.UI.RadDock)
MyDock.Title = sender.title
MyDock =
CType(mpContentPlaceHolder.FindControl("RadDock" & iDockFrom), Telerik.Web.UI.RadDock)
MyDockZone =
CType(mpContentPlaceHolder.FindControl("RadDockZone" & iDockFrom), Telerik.Web.UI.RadDockZone)
MyDock.Dock(MyDockZone.ID)
End Sub
Hi
Could any one suggest me ?
I am facing one problem with radcombo.
When I click on radcombo in the borwser when browser is in normal size (not in maximised size), the radcombo itemlist is coming as drop-up. Unlike normal ASP.NET Dropdownlist, the radcombobox items list is going in side the browser window. But where as an ASP.NET dropdownlist items will be coming on the browser window. (that means the item list will overlap on the browser window).
Is it possible to display the radcombo box itemlist by overlapping it on the browser window ?
Is there any proprety to control/find the itemlist direction (drop-down/drop-up) ?
Thanks in advance.
Balaji Velasiri.
| Protected Sub RadScheduler1_AppointmentInsert(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerCancelEventArgs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'save the appointment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dim tempRadResources As ResourceCollection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dim tempRadResource As Resource | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dim categoryID As Integer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dim categoryName As String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dim calendarID As Long = Val(ddl_calendars.selectedvalue) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Try | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tempRadResources = e.Appointment.Resources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Try | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tempRadResource = tempRadResources.Item(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| categoryID = tempRadResource.Key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| categoryName = tempRadResource.Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Catch ex As Exception | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| categoryID = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| End Try | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dim appStartDate As Date = e.Appointment.Start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dim appEndDate As Date = e.Appointment.End | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dim appTitle As String = e.Appointment.Subject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dim appRecurrenceRule As String = e.Appointment.RecurrenceRule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AppointmentsDataSource.InsertParameters(0).DefaultValue = categoryID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AppointmentsDataSource.InsertParameters(1).DefaultValue = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AppointmentsDataSource.InsertParameters(2).DefaultValue = appStartDate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AppointmentsDataSource.InsertParameters(3).DefaultValue = appEndDate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AppointmentsDataSource.InsertParameters(4).DefaultValue = appTitle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AppointmentsDataSource.InsertParameters(5).DefaultValue = "" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AppointmentsDataSource.InsertParameters(6).DefaultValue = appRecurrenceRule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If e.Appointment.RecurrenceParentID = Nothing Then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AppointmentsDataSource.InsertParameters(7).DefaultValue = Nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ElseIf Val(e.Appointment.RecurrenceParentID) > 0 Then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AppointmentsDataSource.InsertParameters(7).DefaultValue = CLng(e.Appointment.RecurrenceParentID) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| End If | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AppointmentsDataSource.InsertParameters(8).DefaultValue = calendarID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| addedCalendarEvent = True | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dim tempAppointment As Appointment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tempAppointment = New Appointment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tempAppointment = e.Appointment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RadScheduler1.InsertAppointment(tempAppointment) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'e.Cancel = True ' bodge to clear the lingering edit box | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'RadScheduler1.Rebind() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Catch ex As Exception | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
End Try
|
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Telerik.Web.UI;
namespace ITSUS_ITrInno_TelerikWebPart
{
[Guid("e57fdda1-ce58-4d9d-b66a-dfdadd0fea52")]
public class TelerikWebPart : System.Web.UI.WebControls.WebParts.WebPart
{
public TelerikWebPart()
{
}
Label label;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Page.ClientScript.RegisterStartupScript(typeof(TelerikWebPart), this.ID, "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;", true);
if (this.Page.Form != null)
{
string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();")
{
this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
}
}
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
if (scriptManager == null)
{
scriptManager = new RadScriptManager();
this.Page.Form.Controls.Add(scriptManager);
// this.Page.Form.Controls.AddAt(0,scriptManager);
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Panel panel = new Panel();
panel.ID = "Panel1";
this.Controls.Add(panel);
RadTreeView treeView = new RadTreeView();
treeView.ID = "RadTreeView1";
treeView.Nodes.Add(new RadTreeNode("What's the time?"));
treeView.NodeClick += new RadTreeViewEventHandler(treeView_NodeClick);
panel.Controls.Add(treeView);
label = new Label();
label.Text = "This is a label";
panel.Controls.Add(label);
RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(this.Page);
if (ajaxManager == null)
{
ajaxManager = new RadAjaxManager();
ajaxManager.ID = "RadAjaxManager1";
Controls.Add(ajaxManager);
this.Page.Items.Add(typeof(RadAjaxManager), ajaxManager);
}
ajaxManager.AjaxSettings.AddAjaxSetting(treeView, panel);
}
void treeView_NodeClick(object sender, RadTreeNodeEventArgs e)
{
label.Text = DateTime.Now.ToLongTimeString();
}
protected override void CreateChildControls()
{
base.CreateChildControls();
// TODO: add custom rendering code here.
// Label label = new Label();
// label.Text = "Hello World";
// this.Controls.Add(label);
}
}
}