Hi,
Have you sent the demo to me?
Regards,
Allen Chen
Microsoft Online Support
--------------------
| From: "TS" <
[email protected]>
| References: <#
[email protected]>
<#
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
| Subject: Re: overriding GridView.OnRowDeleting - can call registered
event handlers
| Date: Wed, 29 Oct 2008 11:08:23 -0500
| Lines: 1559
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
| X-RFC2646: Format=Flowed; Response
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
| Message-ID: <
[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| NNTP-Posting-Host: 168.38.106.113
| Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP05.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:1147
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| I see now that all the events get raised when I click one of the grid's
| buttons to fire Edit, Update, etc. So on default data binding of the
grid,
| on just load of the page, the events are not getting raised. Sounds like
| something is missing from the control's code:
|
| using System;
| using System.Collections;
| using System.Collections.Specialized;
| using System.Collections.Generic;
| using System.Web.UI.WebControls;
| using System.Web.UI;
| using System.Reflection;
| using MyPrj.SNF.Model;
| using MyPrj.SNF.Application;
| using System.Data;
| using System.Web;
| /// <summary>
| /// Summary description for EditableGrid
| /// </summary>
|
| namespace MyPrj.SNF.Web.Control
| {
|
| public class EditableGrid : System.Web.UI.WebControls.GridView
| {
| public EditableGrid()
| {
| //
| // TODO: Add constructor logic here
| //
| ShowFooter = true;
| ShowHeader = true;
| ShowFooterWhenEmpty = true;
| ShowHeaderWhenEmpty = true;
| ShowGridViewEditButtons = true;
| GridPostbackEvent = "GridReload";
| EmptyDataText = "No Records Found";
| EnableViewState = false;
| SetupStyleAndBehaviour();
| }
|
| #region Events
| #region protected override void OnLoad(EventArgs e)
| protected override void OnLoad(EventArgs e)
| {
| base.OnLoad(e);
| #region Add Delegates for all grid events
| // Add delegates instead of overriding for all the grid events that
dont
| need to call base's implementation, otherwise
| // every aspx page would have to have a delegate for each grid event
that
| was supported for that grid on that page
|
| // Note: do in OnLoad so that the individual aspx pages can also do
this
| in their OnLoad and have their events
| // run first so that the BypassGridEvent flag can be set to true to
| bypass execution here.
| this.RowCommand += new
| GridViewCommandEventHandler(EditableGrid_RowCommand);
| this.RowEditing += new
GridViewEditEventHandler(EditableGrid_RowEditing);
| this.RowCancelingEdit += new
| GridViewCancelEditEventHandler(EditableGrid_RowCancelingEdit);
| this.RowUpdating += new
| GridViewUpdateEventHandler(EditableGrid_RowUpdating);
| this.RowDeleting += new
| GridViewDeleteEventHandler(EditableGrid_RowDeleting);
| this.Sorting += new GridViewSortEventHandler(EditableGrid_Sorting);
| this.PageIndexChanged += new
EventHandler(EditableGrid_PageIndexChanged);
| #endregion
| }
| #endregion
| #region protected override int CreateChildControls(IEnumerable
dataSource,
| bool dataBinding)
| protected override int CreateChildControls(IEnumerable dataSource,
bool
| dataBinding)
| {
| int rows = base.CreateChildControls(dataSource,
dataBinding);
|
| // no data rows created, create empty table if enabled
| if (rows == 0 && (ShowFooterWhenEmpty ||
ShowHeaderWhenEmpty))
| {
| // create the table
| Table table = CreateChildTable();
| Controls.Clear();
| Controls.Add(table);
| DataControlField[] fields;
| if (AutoGenerateColumns)
| {
| PagedDataSource source = new PagedDataSource();
| source.DataSource = dataSource;
| ICollection autoGeneratedColumns =
CreateColumns(source,
| true);
| fields = new
| DataControlField[autoGeneratedColumns.Count];
| autoGeneratedColumns.CopyTo(fields, 0);
| }
| else
| {
| fields = new DataControlField[Columns.Count];
| Columns.CopyTo(fields, 0);
| }
|
| TableRowCollection newRows = table.Rows;
| if (ShowHeaderWhenEmpty)
| {
| // create a new header row
| _headerRow = CreateRow(-1, -1,
| DataControlRowType.Header, DataControlRowState.Normal);
| InitializeRow(_headerRow, fields, newRows);
| }
|
| //// create the empty row
| GridViewRow emptyRow = new GridViewRow(-1, -1,
| DataControlRowType.EmptyDataRow, DataControlRowState.Normal);
| TableCell cell = new TableCell();
| cell.ColumnSpan = fields.Length;
| cell.Width = Unit.Percentage(100);
| //
| if (EmptyDataTemplate != null)
| {
| EmptyDataTemplate.InstantiateIn(cell);
| }
| else if (!string.IsNullOrEmpty(EmptyDataText))
| //else if (!string.IsNullOrEmpty(EmptyDataText) &&
| MyPrj.SNF.Web.Utils.Utils.InReadMode())
| {
| cell.Controls.Add(new
LiteralControl(EmptyDataText));
| }
| emptyRow.Cells.Add(cell);
| GridViewRowEventArgs e = new
GridViewRowEventArgs(emptyRow);
| OnRowCreated(e);
| newRows.Add(emptyRow);
| emptyRow.DataBind();
| OnRowDataBound(e);
| emptyRow.DataItem = null;
| if (ShowFooterWhenEmpty &&
| !MyPrj.SNF.Web.Utils.Utils.InReadMode())
| {
| // create footer row
| _footerRow = CreateRow(-1, -1,
| DataControlRowType.Footer, DataControlRowState.Normal);
| InitializeRow(_footerRow, fields, newRows);
| }
| }
| return rows;
| }
| #endregion
| #region protected override void Render()
| protected override void Render(HtmlTextWriter writer)
| {
| if (DataSource != null && GridMode == GridViewMode.Editable)
| {
| IList listRows = DataSource as IList;
| int rowIndex = 0;
| string itemCountHiddenField = "<input type=\"hidden\"
| name=\"" + this.PropertyName + "Count" + "\" id=\"" + this.PropertyName
+
| "Count" + "\" value=\"" + listRows.Count.ToString() + "\" />";
| writer.WriteLine(itemCountHiddenField);
| foreach (MyPrj.SNF.Model.IDomainObject domainObject in
| listRows)
| {
| foreach (GridViewColumnMetaData columnMetaData in
| MetaData.Columns)
| {
| object propValue =
| Utils.Utils.GetPropertyValue(domainObject, columnMetaData.PropertyName);
| string propertyValue = string.Empty;
| if (propValue != null)
| propertyValue = propValue.ToString();
| // Replace line breaks with a single space
| // Escape Double Quotes & backslashes so the
value
| can be put safely into the array and hidden fields
| propertyValue = propertyValue.Replace("\r\n", "
| ").Replace(@"\", @"\\").Replace(@"""", "\\\"");
|
|
| string hiddenFieldId = (PropertyName + "_" +
| rowIndex + "_" + columnMetaData.PropertyName);
| string hiddenFieldToRender = "<input
type=\"hidden\"
| name=\"" + hiddenFieldId + "\" id=\"" + hiddenFieldId + "\" value=\"" +
| propertyValue + "\" />";
| writer.WriteLine(hiddenFieldToRender);
| }
| rowIndex++;
| }
| }
| base.Render(writer);
| RenderHiddenFieldsForActions();
| }
| #endregion
| #region protected override void LoadControlState()
| /// <summary>
| /// Manages the Sort information.
| /// </summary>
| /// <param name="savedState"></param>
| protected override void LoadControlState(object savedState)
| {
| object[] states = (object[])savedState;
| base.LoadControlState(states[0]);
|
| CSSortExpression = (string)states[1];
| CSSortDirection =
| (MyPrj.SNF.Application.SortDirection)states[2];
| }
| #endregion
| #region protected override object SaveControlState()
| protected override object SaveControlState()
| {
| object[] states = new object[3];
| states[0] = base.SaveControlState();
|
| states[1] = CSSortExpression;
| states[2] = CSSortDirection;
|
| return states;
| }
| #endregion
| protected override void OnDataBinding(EventArgs e)
| {
| DataSource = Utils.Utils.GetPropertyValue(PropertyName) as
| IList;
| addColumns();
| base.OnDataBinding(e);
| }
| protected override void OnRowCreated(GridViewRowEventArgs e)
| {
| if (e.Row.DataItem != null && e.Row.RowType ==
| DataControlRowType.DataRow)
| {
| object isRowDeleted =
| Utils.Utils.GetPropertyValue((IDomainObject)e.Row.DataItem,
| "HasBeenDeleted");
| addRowEvents(e.Row, (bool)isRowDeleted);
| }
|
| #region Add footer row events
| if (MetaData != null && EditIndex < 0 && e.Row.RowType ==
| DataControlRowType.Footer)
| {
| foreach (GridViewActionInfo actionInfo in MetaData.Actions)
| {
| System.Web.UI.WebControls.LinkButton lb = new
| System.Web.UI.WebControls.LinkButton();
| if (actionInfo.EventLocation ==
| GridViewActionInfo.EventLocationCode.FooterRow)
| {
| lb.Text = actionInfo.DisplayName;
| lb.ID = "lnk" + this.ID + actionInfo.EventName;
| lb.CommandName = actionInfo.CommandType.ToString();
| lb.CausesValidation = actionInfo.CausesValidation;
| lb.ValidationGroup = this.ID;
| lb.OnClientClick = getGridEventOnClickString(e.Row,
lb,
| true, 0, actionInfo.CausesValidation,
actionInfo.ClientSideEventHandlerName,
| actionInfo.ActionParameters);
| lb.Attributes.Add("href", "#");
| addActionCell(e.Row, lb);
| TableHeaderCell c = new TableHeaderCell();
| c.Text = "";
| HeaderRow.Cells.Add(c);
| }
| }
| }
| #endregion
|
| base.OnRowCreated(e);
| }
| #region Delegated Events
|
| #region void EditableGrid_RowEditing(object sender,
GridViewEditEventArgs
| e)
| void EditableGrid_RowEditing(object sender, GridViewEditEventArgs e)
| {
| if (BypassGridEvent)
| return;
|
| this.EditIndex = e.NewEditIndex;
| this.DataBind();
| }
| #endregion
| #region void EditableGrid_RowDeleting(object sender,
| GridViewDeleteEventArgs e)
| void EditableGrid_RowDeleting(object sender, GridViewDeleteEventArgs
e)
| {
| if (BypassGridEvent)
| return;
|
| this.EditIndex = -1;
| Type domainObjectType = Type.GetType(DomainObjectName);
| object objItems = Activator.CreateInstance(domainObjectType);
| Array dataSourceItems = DataSource as Array;
| objItems = dataSourceItems.GetValue(e.RowIndex);
| Array updatedItems = getUpdatedItems((IList)DataSource, objItems,
| domainObjectType, e.RowIndex, "HasBeenDeleted", true);
| setPropertyArrayValue(updatedItems);
| this.DataSource = updatedItems as IList;
| this.DataBind();
| }
| #endregion
| #region void EditableGrid_RowUpdating(object sender,
| GridViewUpdateEventArgs e)
| void EditableGrid_RowUpdating(object sender, GridViewUpdateEventArgs
e)
| {
| if (BypassGridEvent)
| return;
|
| this.EditIndex = -1;
| Type domainObjectType = Type.GetType(DomainObjectName);
| object objItems =
Activator.CreateInstance(domainObjectType);
| foreach (System.Web.UI.Control c in
| this.Rows[e.RowIndex].Controls)
| {
| //First level is table cell level.. we need to go one
more
| level..
| if (c is DataControlFieldCell && c.Controls.Count > 0)
| {
| System.Web.UI.Control ec = c.Controls[0] as
| System.Web.UI.Control;
| setEachControlValues(ec, objItems);
| }
| }
|
| Array updatedItems = getUpdatedItems((IList)DataSource,
| objItems, domainObjectType, e.RowIndex, "HasBeenEdited", true);
| setPropertyArrayValue(updatedItems);
| this.DataSource = updatedItems as IList;
| this.DataBind();
| }
| #endregion
| #region void EditableGrid_RowCommand(object sender,
| GridViewCommandEventArgs e)
| void EditableGrid_RowCommand(object sender, GridViewCommandEventArgs
e)
| {
| if (BypassGridEvent)
| return;
|
| #region -- insert new row code here
|
| if (e.CommandName.Equals("Add"))
| {
| //Here we have to get each item value from the controls.
| Type domainObjectType = Type.GetType(DomainObjectName);
| object objItems =
| Activator.CreateInstance(domainObjectType);
| foreach (System.Web.UI.Control c in
this.FooterRow.Controls)
| {
| //First level is table cell level.. we
| //need to go one more level..
| if (c.GetType().Name == "DataControlFieldCell" &&
| c.Controls.Count > 0)
| {
| System.Web.UI.Control ec = c.Controls[0] as
| System.Web.UI.Control;
| setEachControlValues(ec, objItems);
| }
| }
|
| Array addedItems = getAddedItems((IList)DataSource,
| objItems);
| setPropertyArrayValue(addedItems);
| this.DataSource = addedItems as IList;
| this.DataBind();
| }
|
| #endregion
|
| #region -- restore rows here
|
| if (e.CommandName.Equals("Restore"))
| {
| this.EditIndex = -1;
| Type domainObjectType = Type.GetType(DomainObjectName);
| object objItems =
| Activator.CreateInstance(domainObjectType);
| Array dataSourceItems = DataSource as Array;
| objItems =
| dataSourceItems.GetValue(Convert.ToInt32(e.CommandArgument));
| Array updatedItems = getUpdatedItems((IList)DataSource,
| objItems, domainObjectType, Convert.ToInt32(e.CommandArgument),
| "HasBeenDeleted", false);
| setPropertyArrayValue(updatedItems);
| this.DataSource = updatedItems as IList;
| this.DataBind();
| }
|
| #endregion
| }
| #endregion
| #region void EditableGrid_RowCancelingEdit(object sender,
| GridViewCancelEditEventArgs e)
| void EditableGrid_RowCancelingEdit(object sender,
| GridViewCancelEditEventArgs e)
| {
| if (BypassGridEvent)
| return;
|
| this.EditIndex = -1;
| this.DataBind();
| }
| #endregion
| #region void EditableGrid_Sorting(object sender,
| GridViewSortEventArgs e)
| void EditableGrid_Sorting(object sender, GridViewSortEventArgs
e)
| {
| if (BypassGridEvent)
| return;
|
| MyPrj.SNF.Web.Controller.RequestContext
CurrentRequestContext
=
| Context.Items[MyPrj.SNF.Application.Definition.RequestContext] as
| MyPrj.SNF.Web.Controller.RequestContext;
| MyPrj.SNF.Web.Controller.ControllerData
CurrentControllerData
=
| CurrentRequestContext.CurrentControllerData;
|
| if (CSSortExpression !=
| ((GridViewSortEventArgs)e).SortExpression)
| CSSortDirection =
| MyPrj.SNF.Application.SortDirection.Ascending;
| else
| CSSortDirection = (CSSortDirection ==
| MyPrj.SNF.Application.SortDirection.Descending) ?
| MyPrj.SNF.Application.SortDirection.Ascending :
| MyPrj.SNF.Application.SortDirection.Descending;
|
| CSSortExpression =
((GridViewSortEventArgs)e).SortExpression;
| Array.Sort(DataSource as Array, new
| MyPrj.SNF.Application.ClassComparer(CSSortExpression, CSSortDirection));
| this.DataBind();
| }
| #endregion
| #region void EditableGrid_PageIndexChanged(object sender,
EventArgs
| e)
| void EditableGrid_PageIndexChanged(object sender, EventArgs e)
| {
| if (BypassGridEvent)
| return;
|
| bool displayLastPage = false;
| //try
| //{
| if (((GridViewPageEventArgs)e).NewPageIndex > -1)
| PageIndex = ((GridViewPageEventArgs)e).NewPageIndex;
| else
| displayLastPage = true;
| IList list = DataSource as IList;
| if (displayLastPage)
| PageIndex = (int)Math.Ceiling(((double)list.Count /
| PageSize)) - 1;
| this.DataBind();
| //}
| //catch (Exception expGeneral)
| //{
| // throw;
| //}
| }
|
| #endregion
|
| #endregion
| #endregion
|
| #region void addColumns()
|
| private void addColumns()
| {
| if (MetaData == null)
| MetaData =
GridViewMetaData.GetGridViewMetaData(MetaDataId);
| Columns.Clear();
|
| #region - all the controls
|
| foreach (GridViewColumnMetaData columnMetaData in
| MetaData.Columns)
| {
|
| if (columnMetaData.IsDisplayed)
| {
| TemplateField columnField = new TemplateField();
| columnField.HeaderText = columnMetaData.HeaderText;
| if (columnMetaData.IsSortable)
| columnField.SortExpression =
| columnMetaData.SortPropertyName;
| columnField.ItemStyle.HorizontalAlign =
| columnMetaData.HorizontalAlign;
| columnField.ItemStyle.Width = columnMetaData.Width;
|
| if (GridMode == GridViewMode.Editable)
| {
| columnField.ItemTemplate = new
| GridViewTemplate(ListItemType.Item, MetaData, columnMetaData, this.ID);
| columnField.EditItemTemplate = new
| GridViewTemplate(ListItemType.EditItem, MetaData, columnMetaData,
this.ID);
|
| if (!MyPrj.SNF.Web.Utils.Utils.InReadMode() &&
| this.EditIndex < 0)
| {
| columnField.FooterTemplate = new
| GridViewTemplate(ListItemType.Footer, MetaData, columnMetaData,
this.ID);
| }
| }
| //Add the newly created bound field to the GridView.
| Columns.Add(columnField);
| }
| }
|
| #endregion
|
| #region ------- add check box to each row if render
selection
is
| specified
|
|
| if ((MetaData.ShowSelectionInReadMode &&
| MyPrj.SNF.Web.Utils.Utils.InReadMode()) ||
| (MetaData.ShowSelectionInEditableMode &&
| !MyPrj.SNF.Web.Utils.Utils.InReadMode()))
| {
| GridViewColumnMetaData gvMetaData = new
| GridViewColumnMetaData(MetaData.SelectionPropertyName, "Select", false);
| gvMetaData.ColumnType = "DomainObjectSelection";
| TemplateField selectionField = new TemplateField();
| selectionField.ItemTemplate = new
| GridViewTemplate(ListItemType.EditItem, MetaData, gvMetaData, this.ID);
| Columns.Add(selectionField);
| }
|
| #endregion
|
| }
|
|
|
| #endregion
|
| #region private string getControlIndex()
| private string getControlIndex(bool isFooterRow, int
dataRowIndex)
| {
| //This is not a real code......????
| //what do i do if there is no option..
| string controlIndex = "";
| int startCount = 0;
|
| if (isFooterRow)
| {
| startCount = 3;
| if (Rows.Count > 1)
| startCount = 3 + (Rows.Count - 1);
|
| if (startCount < 10)
| controlIndex = "$ctl0" + startCount.ToString() +
"$";
| else
| controlIndex = "$ctl" + startCount.ToString() + "$";
| }
| else
| {
| startCount = 2 + dataRowIndex;
| if (startCount < 10)
| controlIndex = "$ctl0" + startCount.ToString() +
"$";
| else
| controlIndex = "$ctl" + startCount.ToString() + "$";
| }
|
| return controlIndex;
| }
| #endregion
|
| #region private void addRowEvents(GridViewRow gr)
| private void addRowEvents(GridViewRow gr, bool isDeleted)
| {
|
| System.Web.UI.WebControls.LinkButton lb = new
| System.Web.UI.WebControls.LinkButton();
| if (!MyPrj.SNF.Web.Utils.Utils.InReadMode() &&
| ShowGridViewEditButtons)
| {
|
| #region //first add the data row events
|
| foreach (GridViewActionInfo actionInfo in
MetaData.Actions)
| {
| if (actionInfo.EventLocation ==
| GridViewActionInfo.EventLocationCode.DataRow)
| {
| lb = new System.Web.UI.WebControls.LinkButton();
| lb.ID = "lnk" + this.ID + actionInfo.EventName;
| lb.Text = actionInfo.DisplayName;
| lb.CommandName =
actionInfo.CommandType.ToString();
| lb.ValidationGroup = this.ID;
| lb.CausesValidation =
actionInfo.CausesValidation;
| lb.Attributes.Add("href", "#");
| lb.OnClientClick = getGridEventOnClickString(gr,
lb,
| false, gr.RowIndex, actionInfo.CausesValidation,
| actionInfo.ClientSideEventHandlerName, actionInfo.ActionParameters);
|
|
| if (actionInfo.CommandType ==
| GridViewActionInfo.CommandTypeCode.SNF)
| lb.OnClientClick =
| getSNFOnclickString(actionInfo, gr);
| else if (isDeleted && actionInfo.CommandType ==
| GridViewActionInfo.CommandTypeCode.Restore)
| {
| //If its deleted row then just show the
restore
| event and return
| removeActionCell(gr);
| //set the deleted row css class
| gr.CssClass = RemovedItemCssClass;
| lb.CommandArgument = gr.RowIndex.ToString();
| addActionCell(gr, lb);
| addEmptyCell(gr);
| return;
| }
|
|
| bool addThis = false;
| if (EditIndex == gr.RowIndex &&
| (actionInfo.CommandType == GridViewActionInfo.CommandTypeCode.Update ||
| actionInfo.CommandType ==
| GridViewActionInfo.CommandTypeCode.Cancel))
| addThis = true;
| else if (EditIndex < 0 && EditIndex !=
gr.RowIndex
| && (actionInfo.CommandType != GridViewActionInfo.CommandTypeCode.Update
&&
| actionInfo.CommandType !=
| GridViewActionInfo.CommandTypeCode.Cancel && actionInfo.CommandType !=
| GridViewActionInfo.CommandTypeCode.Restore))
| addThis = true;
|
| if (addThis)
| addActionCell(gr, lb);
|
| }
| }
|
| #endregion
|
|
| #region //Add header row for the event
|
| TableHeaderCell c = new TableHeaderCell();
| c.Text = "";
| HeaderRow.Cells.Add(c);
|
| #endregion
|
| }
| }
| #endregion
|
| #region protected void RenderHiddenFieldsForActions()
| protected void RenderHiddenFieldsForActions()
| {
| if (MetaData == null || MetaData.Actions == null ||
| MetaData.Actions.Count < 1 || DataSource == null ||
| ((IList)DataSource).Count == 0)
| return;
|
| Hashtable hiddenFieldIds = new Hashtable();
| foreach (GridViewActionInfo actionInfo in MetaData.Actions)
| {
| if (actionInfo.ActionParameters != null)
| {
| foreach (string argumentName in
| actionInfo.ActionParameters.AllKeys)
| {
| if
| (!hiddenFieldIds.ContainsKey(actionInfo.ActionParameters[argumentName]))
|
hiddenFieldIds[actionInfo.ActionParameters[argumentName]]
| = null;
| }
| }
| }
| foreach (string hiddenFieldId in hiddenFieldIds.Keys)
| {
| // Add the Hidden Field only if the page doesn't already
| contain a control with same ID
| if (!Utils.Utils.IsControlOnPage(Page, hiddenFieldId))
| {
| //For ajax postback we will have to register the
hidden
| fields
| ScriptManager sm = ScriptManager.GetCurrent(Page);
| if (sm != null && sm.IsInAsyncPostBack)
|
System.Web.UI.ScriptManager.RegisterHiddenField(this,
| hiddenFieldId, string.Empty);
| else
|
Page.ClientScript.RegisterHiddenField(hiddenFieldId,
| string.Empty);
| }
| }
| }
| #endregion
|
| #region private string getSNFOnclickString(GridViewActionInfo
| actionInfo,GridViewRow gr)
| private string getSNFOnclickString(GridViewActionInfo
actionInfo,
| GridViewRow gr)
| {
| System.Text.StringBuilder sb = new
System.Text.StringBuilder();
| if (actionInfo.ActionParameters != null &&
| actionInfo.ActionParameters.Count > 0)
| {
| Type gridType = gr.DataItem.GetType();
| List<string> parameters = new List<string>();
| foreach (string propertyName in actionInfo.ActionParameters.AllKeys)
| {
| if (actionInfo.ActionParameters[propertyName] !=
null)
| {
| string controlId =
| actionInfo.ActionParameters[propertyName];
| object propertyValue =
| gridType.GetProperty(propertyName).GetValue(gr.DataItem, null);
| if (PropertyUtilities.IsNullValue(propertyValue))
| propertyValue = string.Empty;
|
| parameters.Add(controlId + "~" + propertyValue);
| }
| }
| object[] args = new object[] { "this",
actionInfo.EventName,
| actionInfo.ClientSideEventHandlerName, string.Join("-",
| parameters.ToArray()), gr.RowIndex };
| return
|
string.Format("processGridViewEvent(\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\")
",
| args);
| }
| return string.Empty;
| }
| #endregion
|
| #region private string getGridEventOnClickString()
| private string getGridEventOnClickString(GridViewRow gridRow,
| System.Web.UI.WebControls.LinkButton lb, bool isFooterRow, int
dataRowIndex,
| bool causeValidation, string clientSideEventHandlerName,
NameValueCollection
| actionParameters)
| {
| string validationGroup = "donotValidate";
| if (causeValidation)
| validationGroup = ID;
|
| string uniqId = this.UniqueID + getControlIndex(isFooterRow,
| dataRowIndex) + lb.UniqueID;
| if (!string.IsNullOrEmpty(clientSideEventHandlerName))
| {
| List<string> parameters = new List<string>();
| parameters.Add("''");
| if (actionParameters != null && actionParameters.Count > 0)
| {
| parameters.Clear();
| Type gridType = gridRow.DataItem.GetType();
| foreach (string propertyName in actionParameters.AllKeys)
| {
| if (actionParameters[propertyName] != null)
| {
| string controlId = actionParameters[propertyName];
| object propertyValue =
| gridType.GetProperty(propertyName).GetValue(gridRow.DataItem, null);
| if (PropertyUtilities.IsNullValue(propertyValue))
| propertyValue = string.Empty;
| parameters.Add(controlId + "~" + propertyValue);
| }
| }
| }
|
| return string.Format("return
|
handleThenFireButtonEvent(\"{0}\",\"{1}\",\"{2}\",{3},\"{4}\",\"{5}\",\"{6}\
",\"{7}\",\"{8}\")",
| "this", GridPostbackEvent, clientSideEventHandlerName, "true",
| string.Join("-", parameters.ToArray()), validationGroup, uniqId,
| lb.CommandArgument, UpdatePanelId);
| }
| object[] args = new object[] { };
| return string.Format("return
|
validateAndFireButtonEventGroup(\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5
}\")",
| "this", GridPostbackEvent, validationGroup, uniqId, lb.CommandArgument,
| UpdatePanelId);
| }
| #endregion
|
| #region private TableRow addActionCell()
| private void addActionCell(GridViewRow gr,
| System.Web.UI.WebControls.LinkButton lb)
| {
| System.Web.UI.WebControls.TableCell tc = new TableCell();
| tc.Controls.Add(lb);
| ((System.Web.UI.WebControls.TableRow)(gr)).Cells.Add(tc);
| }
| #endregion
|
| #region private TableRow addEmptyCell()
| private void addEmptyCell(GridViewRow gr)
| {
| System.Web.UI.WebControls.TableCell tc = new TableCell();
| tc.Text = " ";
| ((System.Web.UI.WebControls.TableRow)(gr)).Cells.Add(tc);
| }
| #endregion
|
| #region private void removeActionCell()
| private void removeActionCell(GridViewRow gr)
| {
| TableCell[] tmpcell = new TableCell[gr.Cells.Count];
| gr.Cells.CopyTo(tmpcell, 0);
| foreach (TableCell c in tmpcell)
| {
| System.Web.UI.Control ctrl = new
System.Web.UI.Control();
| if (c.Controls.Count > 0)
| ctrl = c.Controls[0];
| if (ctrl != null && ctrl.GetType().Name == "LinkButton")
| gr.Cells.Remove(c);
| }
|
| }
| #endregion
|
| #region private void setEachControlValues()
| private void setEachControlValues(System.Web.UI.Control ec,
object
| objItems)
| {
| switch (ec.GetType().Name)
| {
| case "TextBox":
| TextBox ctrlText = (TextBox)ec;
| setControlValue(ctrlText.ID, ctrlText.Text,
objItems);
| break;
| case "HiddenField":
| HiddenField ctrl = (HiddenField )ec;
| setControlValue(ctrl.ID, ctrl.Value, objItems);
| break;
| case "DateBox":
| DateBox ctrlDB = (DateBox)ec;
| setControlValue(ctrlDB.ID, ctrlDB.Text, objItems);
| break;
| case "DateTimeBox":
| DateTimeBox ctrlDTB = (DateTimeBox)ec;
| setControlValue(ctrlDTB.ID, ctrlDTB.Text, objItems);
| break;
| case "CheckBox":
| CheckBox ctrlCheck = (CheckBox)ec;
| string valueToSet = "N";
| if (ctrlCheck.Checked)
| valueToSet = "Y";
| setControlValue(ctrlCheck.ID, valueToSet, objItems);
| break;
| case "DropDownList":
| DropDownList ctrldrp = (DropDownList)ec;
| setControlValue(ctrldrp.ID, ctrldrp.SelectedValue,
| objItems);
| break;
| //also needs to set the ctrldrp.Text to the label
control
| //in the Items templates
| case "RadioButtonList":
| RadioButtonList ctrlRdo = (RadioButtonList)ec;
| setControlValue(ctrlRdo.ID, ctrlRdo.SelectedValue,
| objItems);
| break;
| case "Label":
| Label ctrlLabel = (Label)ec;
| setControlValue(ctrlLabel.ID, ctrlLabel.Text,
objItems);
| break;
| }
|
| }
|
| #endregion
|
| #region public GridViewMetaData MetaData
| private GridViewMetaData _MetaData;
| public GridViewMetaData MetaData
| {
| get { return _MetaData; }
| set { _MetaData = value; }
| }
| #endregion
|
| #region public string DomainObjectName
| private string _domainObjectName;
| public string DomainObjectName
| {
| get { return _domainObjectName; }
| set { _domainObjectName = value; }
| }
| #endregion
|
| #region public string DomainObjectListKey
| private string _DomainObjectListKey;
| public string DomainObjectListKey
| {
| get { return _DomainObjectListKey; }
| set { _DomainObjectListKey = value; }
| }
| #endregion
|
| #region public string MetaDataId
| private string _MetaDataId;
| public string MetaDataId
| {
| get { return _MetaDataId; }
| set { _MetaDataId = value; }
| }
| #endregion
|
| #region public string GridPostbackEvent
| private string _GridPostbackEvent;
| public string GridPostbackEvent
| {
| get { return _GridPostbackEvent; }
| set { _GridPostbackEvent = value; }
| }
| #endregion
|
| #region public bool BypassGridEvent
| private bool _BypassGridEvent = false;
| public bool BypassGridEvent
| {
| get { return _BypassGridEvent; }
| set { _BypassGridEvent = value; }
| }
| #endregion
|
| #region public bool ShowGridViewEditButtons
| private bool _ShowGridViewEditButtons;
| public bool ShowGridViewEditButtons
| {
| get { return _ShowGridViewEditButtons; }
| set { _ShowGridViewEditButtons = value; }
| }
| #endregion
|
| #region public string PropertyName
| private string _PropertyName = string.Empty;
| public string PropertyName
| {
| get { return _PropertyName; }
| set { _PropertyName = value; }
| }
| #endregion
|
| #region private Array getAddedItems()
| private Array getAddedItems(IList oldList, object addedItems)
| {
| MyPrj.SNF.Web.Controller.ControllerData
CurrentControllerData
=
| Utils.Utils.GetCurrentControllerData();
| int arrayLength = 1;
| if (oldList != null && oldList.Count > 0)
| arrayLength = oldList.Count + 1;
| Array arrayItems =
Array.CreateInstance(addedItems.GetType(),
| arrayLength);
| int i = 0;
| if (oldList != null && oldList.Count > 0)
| {
| foreach (IDomainObject dm in oldList)
| {
| arrayItems.SetValue(dm, i);
| i++;
| }
| }
| arrayItems.SetValue(addedItems, i);
| return arrayItems;
| }
| #endregion
|
| #region private Array getUpdatedItems()
| private Array getUpdatedItems(IList oldList, object
updatedItems,
| Type domainObjectType, int rowIndex, string propertyToUpdate, bool
value)
| {
| //Also set the HasBeenEdited/HasBeenDeleted field with the
value
| true/false..
| setControlValue(propertyToUpdate, value, updatedItems);
| MyPrj.SNF.Web.Controller.ControllerData
CurrentControllerData
=
| Utils.Utils.GetCurrentControllerData();
| Array arrayItems = Array.CreateInstance(domainObjectType,
| oldList.Count);
| int i = 0;
| foreach (IDomainObject dm in oldList)
| {
| if (i == rowIndex)//if the row index match the current object then
| replace the displayed column's values with the updated one
| {
| foreach (GridViewColumnMetaData columnMetaData in MetaData.Columns)
| {
| if (columnMetaData.IsDisplayed)
| {
| PropertyUtilities.SetValue(dm, columnMetaData.PropertyName,
| PropertyUtilities.GetValue((IDomainObject)updatedItems,
| columnMetaData.PropertyName));
| }
| }
| }
| // also set hasbeenEdited/hasbeenDeleted with true/false
| setControlValue(propertyToUpdate, value, dm);
| arrayItems.SetValue(dm, i);
| i++;
| }
| return arrayItems;
| }
| #endregion
|
| #region private Array getRemovedItems()
| private Array getRemovedItems(IList oldList, object
removedItems,
| int rowIndex)
| {
| MyPrj.SNF.Web.Controller.ControllerData
CurrentControllerData
=
| Utils.Utils.GetCurrentControllerData();
| Array arrayItemsToCopy =
| Array.CreateInstance(removedItems.GetType(), oldList.Count);
| Array arrayItems =
Array.CreateInstance(removedItems.GetType(),
| oldList.Count - 1);
| int i = 0;
| foreach (IDomainObject dm in oldList)
| {
| if (i != rowIndex)//if the row index match the current
| object then remove it(do not add to list)
| arrayItemsToCopy.SetValue(dm, i);
| i++;
| }
|
| int newArrayCount = 0;
| for (int j = 0; j < arrayItemsToCopy.Length; j++)
| {
| if (arrayItemsToCopy.GetValue(j) != null)
| {
| arrayItems.SetValue(arrayItemsToCopy.GetValue(j),
| newArrayCount);
| newArrayCount++;
| }
| }
|
| return arrayItems;
| }
| #endregion
|
| #region private void setControlValue()
| private void setControlValue(string propertyName, object value,
| object dObject)
| {
| PropertyInfo pi = null;
| pi = dObject.GetType().GetProperty(propertyName);
| SNF.Model.PropertyUtilities.SetValue((IDomainObject)dObject,
pi,
| value);
|
| }
| #endregion
|
| #region private void setPropertyArrayValue()
| private void setPropertyArrayValue(Array arrayItems)
| {
|
| MyPrj.SNF.Web.Controller.ControllerData
CurrentControllerData
=
| Utils.Utils.GetCurrentControllerData();
| IDomainObject domainObject =
CurrentControllerData.DomainObject;
| PropertyInfo pi =
| domainObject.GetType().GetProperty(PropertyName);
| pi.SetValue(domainObject, arrayItems, null);
| }
| #endregion
|
| #region private void ProcessControllerEvent()
| private void ProcessControllerEvent(string eventName)
| {
| // Process the current event
|
| MyPrj.SNF.Web.Controller.RequestContext
CurrentRequestContext
=
| Context.Items[MyPrj.SNF.Application.Definition.RequestContext] as
| MyPrj.SNF.Web.Controller.RequestContext;
| MyPrj.SNF.Web.Controller.ControllerData
CurrentControllerData
=
| CurrentRequestContext.CurrentControllerData;
| CurrentControllerData.EventName = eventName;
|
| MyPrj.SNF.Web.Controller.ProcessResult pr =
| MyPrj.SNF.Web.Controller.EventProcessor.ProcessEvent(
| CurrentRequestContext, CurrentControllerData.StateId,
| CurrentControllerData.EventName);
|
| CurrentControllerData.EventName = pr.EventName; // Capture
the
| EventName from the result;
| }
| #endregion
|
| #region private void addAjaxSupport()
| private void addAjaxSupport(bool add)
| {
| ScriptManager
| sm = ScriptManager.GetCurrent(Page);
| if (sm == null)
| throw new HttpException("A ScriptManager control must
exist
| on the current page.");
| UpdatePanel updatePanel = new UpdatePanel();
| updatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
| updatePanel.ID = "updatePanel" + this.ID;
| updatePanel.ContentTemplateContainer.Controls.Add(this);
| this.Controls.Add(updatePanel);
| }
| #endregion
|
| #region -- section to show/hide empty header and footer rows
|
| private GridViewRow _headerRow;
| private GridViewRow _footerRow;
|
| private bool _showHeaderWhenEmpty;
| private bool _showFooterWhenEmpty;
|
| public bool ShowHeaderWhenEmpty
| {
| get { return _showHeaderWhenEmpty; }
| set { _showHeaderWhenEmpty = value; }
| }
|
| public bool ShowFooterWhenEmpty
| {
| get { return _showFooterWhenEmpty; }
| set { _showFooterWhenEmpty = value; }
| }
|
| public override GridViewRow HeaderRow
| {
| get { return base.HeaderRow ?? _headerRow; }
| }
|
| public override GridViewRow FooterRow
| {
| get { return base.FooterRow ?? _footerRow; }
| }
|
| private void InitializeRow(GridViewRow row, DataControlField[]
| fields, TableRowCollection newRows)
| {
| GridViewRowEventArgs e = new GridViewRowEventArgs(row);
| InitializeRow(row, fields);
| OnRowCreated(e);
| newRows.Add(row);
| row.DataBind();
| OnRowDataBound(e);
| row.DataItem = null;
| }
|
| #endregion
|
| #region protected void SetupStyleAndBehaviour ()
| protected virtual void SetupStyleAndBehaviour()
| {
| EnableViewState = false;
| AutoGenerateColumns = false;
|
| AllowSorting = true;
| AllowPaging = true;
| EnableSortingAndPagingCallbacks = false;
| AutoGenerateSelectButton = false;
| AutoGenerateDeleteButton = false;
| AutoGenerateEditButton = false;
|
| ShowHeader = true;
| ShowFooter = true;
| EmptyDataText = "No records found";
|
| CssClass = "grid";
| CellPadding = 3;
| CellSpacing = 0;
| GridLines = GridLines.Horizontal;
|
| PageSize = 20;
| PagerStyle.CssClass = "gridPager";
| PagerSettings.FirstPageText = "<<";
| PagerSettings.PreviousPageText = "<";
| PagerSettings.NextPageText = ">";
| PagerSettings.LastPageText = ">>";
| PagerSettings.PageButtonCount = 10;
| PagerSettings.Mode = PagerButtons.NumericFirstLast;
|
| RowStyle.CssClass = "gridRow";
| SelectedRowStyle.CssClass = "gridSelectedRow";
| HeaderStyle.CssClass = "gridViewHeader";
| FooterStyle.CssClass = "gridfooter";
| AlternatingRowStyle.CssClass = "gridAlternatingRow";
| RemovedItemCssClass = "gridDeletedRow";
| }
| #endregion
|
| #region public GridViewMode GridMode
| private GridViewMode _GridMode = GridViewMode.Editable;
| /// <summary>
| ///
| /// </summary>
| public GridViewMode GridMode
| {
| get { return _GridMode; }
| set { _GridMode = value; }
| }
| #endregion
|
| #region Custom Management of SortExpression & SortDirection
|
| #region public string CSSortExpression
| private string _CSSortExpression;
| public string CSSortExpression
| {
| get { return _CSSortExpression; }
| set { _CSSortExpression = value; }
| }
| #endregion
|
| #region public SortDirection CSSortDirection
| private MyPrj.SNF.Application.SortDirection _CSSortDirection;
| public MyPrj.SNF.Application.SortDirection CSSortDirection
| {
| get { return _CSSortDirection; }
| set { _CSSortDirection = value; }
| }
| #endregion
|
| #endregion Custom Management of SortExpression & SortDirection
|
| #region public string RemovedItemCssClass
| private string _RemovedItemCssClass;
| public string RemovedItemCssClass
| {
| get { return _RemovedItemCssClass; }
| set { _RemovedItemCssClass = value; }
| }
| #endregion
|
| #region public string UpdatePanelId
| private string _UpdatePanelId;
| public string UpdatePanelId
| {
| get { return _UpdatePanelId; }
| set { _UpdatePanelId = value; }
| }
| #endregion
| }
| }
|
|
|
| | > hello, I have 2 new issues:
| >
| > 1. My control is overriding OnRowCreated and it calls
base.OnRowCreated
| > and on my aspx.cs page i am attaching an event handler to this
RowCreated
| > but it is not running. I also tried to add an event handler to
| > RowDataBound and calling base.OnRowDataBound and it doesnt get called
in
| > aspx.cs either.
| >
| > What could be the cause of this? I dont understand since i'm calling
base
| > implementation (which seeing the code thru reflector it calls any
attached
| > handlers)
| >
| > 2. This is related somehow to first point. As stated in the first
problem
| > you already resolved, i attached event handlers in my custom control
| > instead of overriding them and that caused my event handlers on
aspx.cs
| > page to be called correctly for most of them. When i tried to attach
event
| > handler for RowCreated in custom control, it is not called, but when I
| > override OnRowCreated it is called. Even when I attached event handler
for
| > RowCreated in custom control AND aspx.cs page, neither were called.
The
| > grid events that I am currently using successfully on aspx.cs are
| > RowUpdating and RowEditing, both of which are also attached event
handlers
| > in custom control.
| >
| > thanks
| >
| > | >> Hi,
| >>
| >> Do you have any further questions? If you have please provide some
code
| >> so
| >> that I can test it on my side.
| >>
| >> Regards,
| >> Allen Chen
| >> Microsoft Online Community Support
| >>
| >> --------------------
| >> | From: "TS" <
[email protected]>
| >> | References: <#
[email protected]>
| >> <#
[email protected]>
| >> <
[email protected]>
| >> <
[email protected]>
| >> | Subject: Re: overriding GridView.OnRowDeleting - can call
registered
| >> event handlers
| >> | Date: Wed, 22 Oct 2008 11:07:08 -0500
| >> | Lines: 223
| >> | X-Priority: 3
| >> | X-MSMail-Priority: Normal
| >> | X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
| >> | X-RFC2646: Format=Flowed; Original
| >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
| >> | Message-ID: <
[email protected]>
| >> | Newsgroups:
microsoft.public.dotnet.framework.aspnet.buildingcontrols
| >> | NNTP-Posting-Host: 168.38.106.193
| >> | Path:
TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
| >> | Xref: TK2MSFTNGHUB02.phx.gbl
| >> microsoft.public.dotnet.framework.aspnet.buildingcontrols:1142
| >> | X-Tomcat-NG:
microsoft.public.dotnet.framework.aspnet.buildingcontrols
| >> |
| >> | that did it, but for some reason the delegates for DataBinding was
not
| >> | getting called, but that method does call base.DataBind, so make it
| >> | overridable is OK, though not sure why it wasnt getting called
| >> |
message
| >> | | >> | > Hi,
| >> | >
| >> | > Thanks for your clarification. To achieve your requirement I
would
| >> suggest
| >> | > you attach an event handler in the constructor method instead of
| >> | > overriding
| >> | > the OnRowDeleting method.
| >> | >
| >> | > public class MyGridView : GridView
| >> | > {
| >> | >
| >> | > public MyGridView()
| >> | > {
| >> | > this.RowDeleting += new
| >> | > GridViewDeleteEventHandler(MyGridView_RowDeleting);
| >> | > }
| >> | > void MyGridView_RowDeleting(object sender,
| >> GridViewDeleteEventArgs
| >> | > e)
| >> | > {
| >> | > //Your code here
| >> | > }
| >> | > }
| >> | >
| >> | > Please have a try and let me know if it's what you need.
| >> | >
| >> | > Regards,
| >> | > Allen Chen
| >> | > Microsoft Online Support
| >> | >
| >> | > --------------------
| >> | > | From: "TS" <
[email protected]>
| >> | > | References: <#
[email protected]>
| >> | > <#
[email protected]>
| >> | > | Subject: Re: overriding GridView.OnRowDeleting - can call
| >> registered
| >> | > event handlers
| >> | > | Date: Tue, 21 Oct 2008 11:38:04 -0500
| >> | > | Lines: 136
| >> | > | X-Priority: 3
| >> | > | X-MSMail-Priority: Normal
| >> | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
| >> | > | X-RFC2646: Format=Flowed; Original
| >> | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
| >> | > | Message-ID: <
[email protected]>
| >> | > | Newsgroups:
| >> microsoft.public.dotnet.framework.aspnet.buildingcontrols
| >> | > | NNTP-Posting-Host: 168.38.106.193
| >> | > | Path:
| >> TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP03.phx.gbl
| >> | > | Xref: TK2MSFTNGHUB02.phx.gbl
| >> | > microsoft.public.dotnet.framework.aspnet.buildingcontrols:1140
| >> | > | X-Tomcat-NG:
| >> microsoft.public.dotnet.framework.aspnet.buildingcontrols
| >> | > |
| >> | > | So it looks like the "else if" section of the posted code below
is
| >> | > getting
| >> | > | run, which throws an exception and this is why that
| >> base.OnRowDeleting
| >> | > is
| >> | > | commented out. Our custom OnRowDeleting does a lot of stuff in
it
| >> that
| >> | > is
| >> | > | common to every grid. The only thing the base class does is
call
| >> any
| >> | > | registered delegates. So if we dont add event handler in aspx
page
| >> for
| >> | > | onRowDeleting, the base class will throw this error.
| >> | > |
| >> | > | We want to not have to attach custom event handlers in every
aspx
| >> page
| >> | > that
| >> | > | uses the grid control and just let our custom gridView handle
all
| >> the
| >> | > | processing in all the grid events (onRowEditing, onRowUpdating,
| >> | > | onRowDeleting, etc.), but I need to be able to support
overriding
| >> this
| >> | > | behavior sometimes by adding a custom event handler in my aspx
| >> page.
| >> | > |
| >> | > | Could I override the each Event Handler's add/remove properties
so
| >> that
| >> | > i
| >> | > | can handle the Event[] collection myself and then i'll be able
to
| >> call
| >> | > the
| >> | > | individually registered delegates?
| >> | > | public event GridViewDeleteEventHandler RowDeleting
| >> | > |
| >> | > | {
| >> | > |
| >> | > | add
| >> | > |
| >> | > | {
| >> | > |
| >> | > | base.Events.AddHandler(EventRowDeleting, value);
| >> | > |
| >> | > | }
| >> | > |
| >> | > | remove
| >> | > |
| >> | > | {
| >> | > |
| >> | > | base.Events.RemoveHandler(EventRowDeleting, value);
| >> | > |
| >> | > | }
| >> | > |
| >> | > | }
| >> | > |
| >> | > |
| >> message
| >> | > | | >> | > | > Hi,
| >> | > | >
| >> | > | > As you said, it's a private field so we cannot access it in
the
| >> custom
| >> | > | > GridView. I think we'd better focus on your following
statement:
| >> | > | >
| >> | > | > I have a custom GridView and it overrides onRowDeleting and
| >> doesn't
| >> | > | > call base.OnRowDeleting because the person implementing had
| >> | > undesirable
| >> | > | > effects.
| >> | > | >
| >> | > | > Could you tell me what're the undesirable effects and your
| >> requirement
| >> | > as
| >> | > | > well? I think if we can eliminate them this issue can be
worked
| >> | > around.
| >> | > | >
| >> | > | > Regards,
| >> | > | > Allen Chen
| >> | > | > Microsoft Online Support
| >> | > | >
| >> | > | > Delighting our customers is our #1 priority. We welcome your
| >> comments
| >> | > and
| >> | > | > suggestions about how we can improve the support we provide
to
| >> you.
| >> | > Please
| >> | > | > feel free to let my manager know what you think of the level
of
| >> | > service
| >> | > | > provided. You can send feedback directly to my manager at:
| >> | > | > (e-mail address removed).
| >> | > | >
| >> | > | > ==================================================
| >> | > | > Get notification to my posts through email? Please refer to
| >> | > | >
| >> | >
| >>
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
| >> | > | >
| >> | > | > Note: The MSDN Managed Newsgroup support offering is for
| >> non-urgent
| >> | > issues
| >> | > | > where an initial response from the community or a Microsoft
| >> Support
| >> | > | > Engineer within 1 business day is acceptable. Please note
that
| >> each
| >> | > follow
| >> | > | > up response may take approximately 2 business days as the
support
| >> | > | > professional working with you may need further investigation
to
| >> reach
| >> | > the
| >> | > | > most efficient resolution. The offering is not appropriate
for
| >> | > situations
| >> | > | > that require urgent, real-time or phone-based interactions or
| >> complex
| >> | > | > project analysis and dump analysis issues. Issues of this
nature
| >> are
| >> | > best
| >> | > | > handled working with a dedicated Microsoft Support Engineer
by
| >> | > contacting
| >> | > | > Microsoft Customer Support Services (CSS) at
| >> | > | >
| >> | >
| >>
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
| >> | > | > ==================================================
| >> | > | > This posting is provided "AS IS" with no warranties, and
confers
| >> no
| >> | > | > rights.
| >> | > | >
| >> | > | > --------------------
| >> | > | > | From: "TS" <
[email protected]>
| >> | > | > | Subject: overriding GridView.OnRowDeleting - can call
| >> registered
| >> | > event
| >> | > | > handlers
| >> | > | > | Date: Mon, 20 Oct 2008 16:17:30 -0500
| >> | > | > | Lines: 24
| >> | > | > | X-Priority: 3
| >> | > | > | X-MSMail-Priority: Normal
| >> | > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
| >> | > | > | X-RFC2646: Format=Flowed; Original
| >> | > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
| >> | > | > | Message-ID: <#
[email protected]>
| >> | > | > | Newsgroups:
| >> | > microsoft.public.dotnet.framework.aspnet.buildingcontrols
| >> | > | > | NNTP-Posting-Host: 168.38.106.193
| >> | > | > | Path:
| >> | > TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
| >> | > | > | Xref: TK2MSFTNGHUB02.phx.gbl
| >> | > | >
microsoft.public.dotnet.framework.aspnet.buildingcontrols:1138
| >> | > | > | X-Tomcat-NG:
| >> | > microsoft.public.dotnet.framework.aspnet.buildingcontrols
| >> | > | > |
| >> | > | > | Hello, I have a custom GridView and it overrides
onRowDeleting
| >> and
| >> | > | > doesn't
| >> | > | > | call base.OnRowDeleting because the person implementing had
| >> | > undesirable
| >> | > | > | effects. the problem is I now when clients of this control
| >> register
| >> | > | > their
| >> | > | > | own event handlers for RowDeleting, it is never raised.
| >> | > | > |
| >> | > | > | I'm trying to add lines 1 - 5 to my overriden OnRowDeleting
| >> method
| >> | > but
| >> | > | > can't
| >> | > | > | because the key accessed in base.Events is
EventRowDeleting,
| >> which
| >> | > is
| >> | > an
| >> | > | > | object that is a private constant that i dont have access
to
in
| >> my
| >> | > | > derived
| >> | > | > | control.
| >> | > | > |
| >> | > | > | How do I get a handle to any event handlers so I can call
| >> them???
| >> | > | > |
| >> | > | > | // this is the dissasembled method for GridView:
| >> | > | > | protected virtual void
OnRowDeleting(GridViewDeleteEventArgs
| >> e){
| >> | > | > bool
| >> | > | > | isBoundUsingDataSourceID = base.IsBoundUsingDataSourceID;1
| >> | > | > | GridViewDeleteEventHandler handler =
| >> (GridViewDeleteEventHandler)
| >> | > | > | base.Events[EventRowDeleting];2 if (handler != null)3
{4
| >> | > | > | handler(this, e);5 } else if
(!isBoundUsingDataSourceID
| >> &&
| >> | > | > !e.Cancel)
| >> | > | > | { throw new
| >> | > | > HttpException(SR.GetString("GridView_UnhandledEvent",
| >> | > | > | new object[] { this.ID, "RowDeleting" })); }}
| >> | > | > |
| >> | > | > |
| >> | > | > |
| >> | > | > |
| >> | > | > |
| >> | > | >
| >> | > |
| >> | > |
| >> | > |
| >> | >
| >> |
| >> |
| >> |
| >>
| >
| >
|
|
|