Public
ERR_DESC As String = ""
And set this on the Itemupdate() event:
Sys.Application.add_load(applicationLoadHandler);
function applicationLoadHandler() {
debugger;
var ERR_DESC='<%=ERR_DESC%>';
if (ERR_DESC!='') {
var oWnd = radopen("RTS_Message_Window.aspx?message="+ERR_DESC+"&title=Problem Running Report" , "RadWindow1" );
oWnd.setSize (300, 200);
oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close);
}
}
| public override System.Web.UI.Control GetControl(System.Data.DataRow dr) |
| { |
| ItemData = dr; |
| Telerik.Web.UI.RadAjaxPanel pnl = new Telerik.Web.UI.RadAjaxPanel(); |
| //System.Web.UI.WebControls.Panel pnl = new System.Web.UI.WebControls.Panel(); |
| pnl.Width = this.Width; |
| pnl.ID = this.ID; |
| pnl.Visible = this.Visible; |
| pnl.Attributes.Add("Style", string.Format("position: absolute;left: {0}px; Top:{1}px;z-index:{2};", this.Left, this.Top , this.zIndex)); |
| pnl.Width = this.Width; |
| pnl.Height = this.Height; |
| Telerik.Web.UI.RadGrid _RadGrid = new Telerik.Web.UI.RadGrid(); |
| _RadGrid.Width = this.Width; |
| _RadGrid.Height = this.Height; |
| _RadGrid.Visible = this.Visible; |
| _RadGrid.ClientSettings.Scrolling.AllowScroll = true; |
| _RadGrid.ID = "grd_" + this.ID; |
| //_RadGrid.AllowAutomaticInserts = true; |
| //_RadGrid.AllowAutomaticUpdates = true; |
| if (!this.ReadOnly) |
| { |
| _RadGrid.MasterTableView.CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.Top; |
| _RadGrid.MasterTableView.CommandItemSettings.AddNewRecordText = "اضافه کردن رکورد جدید"; |
| _RadGrid.MasterTableView.CommandItemSettings.RefreshText = "بروز رسانی"; |
| _RadGrid.Attributes.Add("Style", string.Format("position: absolute;left: {0}px; Top:{1}px;", 0, 0)); |
| _RadGrid.Height = this.Height; |
| //_RadGrid.MasterTableView.EditMode = Telerik.Web.UI.GridEditMode.InPlace; |
| } |
| //_RadGrid.MasterTableView.EditFormSettings.PopUpSettings. ZIndex = 15000; |
| _RadGrid.MasterTableView.EditFormSettings.FormStyle.BackColor = System.Drawing.Color.WhiteSmoke; |
| _RadGrid.Skin = "Office2007"; |
| _RadGrid.MasterTableView.EditFormSettings.EditFormType = Telerik.Web.UI.GridEditFormType.WebUserControl; |
| //_RadGrid.ClientSettings.ClientEvents.OnPopUpShowing = "PopUpShowing"; // this function must exist in Master Page ;) |
| _RadGrid.MasterTableView.EditFormSettings.UserControlName = "~/FormGeneratorTools/UCLoadForm.ascx"; |
| _RadGrid.MasterTableView.DataKeyNames =new string[1]{string.Format("frm{0}Id", BindingFormID)}; |
| _RadGrid.NeedDataSource += new GridNeedDataSourceEventHandler(_RadGrid_NeedDataSource); |
| _RadGrid.ItemCommand += new GridCommandEventHandler(_RadGrid_ItemCommand); |
| _RadGrid.InsertCommand += new GridCommandEventHandler(_RadGrid_InsertCommand); |
| _RadGrid.UpdateCommand += new GridCommandEventHandler(_RadGrid_UpdateCommand); |
| _RadGrid.DeleteCommand += new GridCommandEventHandler(_RadGrid_DeleteCommand); |
| AddcolumntoGrid(_RadGrid); |
| _RadGrid.AutoGenerateColumns = false; |
| object objj = _RadGrid.DataSource; |
| pnl.Controls.Add(_RadGrid); |
| return pnl; |
| } |
| void _RadGrid_DeleteCommand(object source, GridCommandEventArgs e) |
| { |
| string ID = (e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex][string.Format("frm{0}Id", BindingFormID)].ToString(); |
| if (((RadGrid)source).Page.Session["Data_" + BindingFormID] != null) |
| { |
| System.Data.DataSet ds = (System.Data.DataSet)((RadGrid)source).Page.Session["Data_" + BindingFormID]; |
| if (ds.Tables[0].Rows.Find(ID) != null) |
| { |
| ds.Tables[0].Rows.Find(ID).Delete(); |
| ds.Tables[0].AcceptChanges(); |
| } |
| } |
| } |
| void _RadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| System.Data.DataSet ds = new System.Data.DataSet(); |
| if (e.RebindReason == GridRebindReason.InitialLoad) |
| ((RadGrid)source).Page.Session["Data_" + BindingFormID] = GetData(); |
| if (((RadGrid)source).Page.Session["Data_" + BindingFormID] != null) |
| ds.Merge((System.Data.DataSet)((RadGrid)source).Page.Session["Data_" + BindingFormID]); |
| if(ds!=null) |
| ((RadGrid)source).DataSource = ds; |
| } |
| void _RadGrid_InsertCommand(object source, GridCommandEventArgs e) |
| { |
| GridEditableItem editedItem = e.Item as GridEditableItem; |
| UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); |
| object obj = userControl.FindControl("Co_" + BindingFormID); |
| System.Data.DataSet dsNewData = ((WebForm)obj).GetDate(userControl.Request); |
| string CurrentID = "0"; |
| if (userControl.Session["Data_" + BindingFormID] != null) |
| { |
| if((((System.Data.DataSet)userControl.Session["Data_" + BindingFormID])).Tables[0].Rows.Count!=0) |
| CurrentID = (((System.Data.DataSet)userControl.Session["Data_" + BindingFormID])).Tables[0].Select(string.Format("frm{0}Id > 0", BindingFormID), string.Format("frm{0}Id DESC", BindingFormID))[0][string.Format("frm{0}Id", BindingFormID)].ToString(); |
| dsNewData.Tables[0].Rows[0][string.Format("frm{0}Id", BindingFormID)] = long.Parse(CurrentID) + 1; |
| dsNewData.Merge((System.Data.DataSet)userControl.Session["Data_" + BindingFormID]); |
| } |
| else |
| dsNewData.Tables[0].Rows[0][string.Format("frm{0}Id", BindingFormID)] = long.Parse(CurrentID); |
| userControl.Session["Data_" + BindingFormID] = dsNewData; |
| } |
| /// <summary> |
| /// |
| /// </summary> |
| /// <param name="source"></param> |
| /// <param name="e"></param> |
| void _RadGrid_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| ((Telerik.Web.UI.GridBaseDataList)(source)).Page.Session["FormID"] = BindingFormID; |
| } |
| /// <summary> |
| /// |
| /// </summary> |
| /// <param name="source"></param> |
| /// <param name="e"></param> |
| void _RadGrid_UpdateCommand(object source, GridCommandEventArgs e) |
| { |
| GridEditableItem editedItem = e.Item as GridEditableItem; |
| UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); |
| object obj = userControl.FindControl("Co_" + BindingFormID); |
| System.Data.DataSet dsNewData = ((WebForm)obj).GetDate(userControl.Request); |
| string ID = (e.Item as GridEditFormItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex][string.Format("frm{0}Id", BindingFormID)].ToString(); |
| if (userControl.Session["Data_" + BindingFormID] != null) |
| { |
| dsNewData.Tables[0].Rows[0][string.Format("frm{0}Id", BindingFormID)] = ID; |
| if(((System.Data.DataSet)userControl.Session["Data_" + BindingFormID]).Tables[0].Rows.Find(ID)!=null) |
| ((System.Data.DataSet)userControl.Session["Data_" + BindingFormID]).Tables[0].Rows.Find(ID).Delete(); |
| ((System.Data.DataSet)userControl.Session["Data_" + BindingFormID]).AcceptChanges(); |
| dsNewData.Merge((System.Data.DataSet)userControl.Session["Data_" + BindingFormID]); |
| } |
| userControl.Session["Data_" + BindingFormID] = dsNewData; |
| } |
function OpenPositionedWindow(oButton, url, windowName) {
var oWnd = window.radopen(url, windowName);
}
function openWin() {
var oWnd = radopen("http://www.google.com", "RadWindow1");
oWnd.setSize(500, 500);
oWnd.center();
<
button onclick="openWin(); return false;">Test</button>
I am using Q1 2009.
| protected void AppointmentsGrid_DeleteCommand( object source, GridCommandEventArgs e ) |
| { |
| DALDataContext dc = new DALDataContext(); |
| int appointmentID = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["AppointmentID"]; |
| dc.Appointments.DeleteOnSubmit(dc.GetAppointmentByID(appointmentID)); |
| dc.SubmitChanges(); |
| AppointmentsGrid.DataBind(); |
| } |
| DALDataContext dc = new DALDataContext(); |
| vw_Appointment appointment = (vw_Appointment)e.Item.DataItem; |
| dc.Appointments.DeleteOnSubmit(dc.GetAppointmentByID(appointment.AppointmentID)); |
| dc.SubmitChanges(); |

| <telerik:GridDropDownColumn DataField="SubscriptionID" HeaderText="Subscription" |
| ListTextField="SubscriptionDescription" ListValueField="SubscriptionTypeID" UniqueName="SubscriptionTypeID"/> |
| protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| if (!_isBound) |
| { |
| CapitalPortalDataContext db = new CapitalPortalDataContext(); |
| var nSubscriptions = from s in db.Subscriptions.Where(s => (bool)s.Active) |
| select new |
| { |
| s.SubscriptionTypeID, |
| s.SubscriptionDescription |
| }; |
| (((GridDropDownColumnEditor) |
| ((GridDropDownColumn)RadGrid1.MasterTableView.GetColumnSafe("SubscriptionTypeID")).ColumnEditor)).DataSource = nSubscriptions; |
| _isBound = true; |
| } |
| } |
| } |