我有一个radgrid用户控件(rgTask
),该用户控件具有另一个用户控件(ContractTaskInput
)作为编辑表单。 rgTask
分两页(ContractDetail
和LeasingContractDetail
)。
我已将这些事件公开,因此页面可以不同地使用它们
public partial class ContractTaskGrid : System.Web.UI.UserControl
{
public event EventHandler<GridNeedDataSourceEventArgs> NeedDataSource;
public event EventHandler<GridCommandEventArgs> UpdateCommand;
public event EventHandler<GridCommandEventArgs> DeleteCommand;
public event EventHandler<GridCommandEventArgs> InsertCommand;
public event EventHandler<GridItemEventArgs> ItemDataBound;
void OnUpdateCommand(object sender, GridCommandEventArgs e)
{
if (UpdateCommand != null)
{
UpdateCommand(sender, e);
}
}
void OnDeleteCommand(object sender, GridCommandEventArgs e)
{
if (DeleteCommand != null)
{
DeleteCommand(sender, e);
}
}
void OnInsertCommand(object sender, GridCommandEventArgs e)
{
System.Diagnostics.Debug.WriteLine("InsertCommandnull?");
if (InsertCommand != null)
{
System.Diagnostics.Debug.WriteLine("InsertCommandnotnull");
InsertCommand(sender, e);
}
}
void OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
if (NeedDataSource != null)
{
NeedDataSource(sender, e);
}
}
void OnItemDataBound(object sender, GridItemEventArgs e)
{
if (ItemDataBound != null)
{
ItemDataBound(sender, e);
}
}
public RadGrid Grid
{
get { return rgTask; }
}
protected void Page_Load(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Load Grid");
}
protected void rgTask_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
OnNeedDataSource(sender, e);
}
protected void rgTask_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
OnUpdateCommand(sender, e);
}
protected void rgTask_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
OnDeleteCommand(sender, e);
}
protected void rgTask_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
System.Diagnostics.Debug.WriteLine("rgTask_InsertCommand run assigned");
OnInsertCommand(sender, e);
}
protected void rgTask_ItemDataBound(object sender, GridItemEventArgs e)
{
OnItemDataBound(sender, e);
}
}
所有事件在ContractDetail
页上都可以正常工作,但是只有InsertCommand
和UpdateCommand
在LeasingContractDetail
页上无法正常工作。
下面是ContractTaskInput
控件
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ContractTaskInput.ascx.cs" Inherits="EBT.Web.Control.BillingModule.ContractTaskInput" %>
<div class="divStyle">
<table>
<tr>
<td>
Assigned To:
</td>
<td>
<telerik:RadComboBox ID="rcbAssignedTo" runat="server" Filter="Contains"
Width="200px" DropDownAutoWidth="Enabled" OnDataBinding="rcbAssignedTo_DataBinding"
AutoPostBack="false" CausesValidation="false">
</telerik:RadComboBox>
</td>
</tr>
<tr>
<td>
Assigned Task:
</td>
<td><telerik:RadTextBox ID="txtAssignedTask" runat="server" Width="500px"
MaxLength="5000" TextMode="MultiLine" Rows="7" Columns="40">
</telerik:RadTextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="rfAssignedTask" runat="server"
ErrorMessage="* Required" ValidationGroup="ActivityValidation"
ControlToValidate="txtAssignedTask"
Display="Dynamic" ForeColor="Red" />
</td>
</tr>
<tr>
<td>
Status:
</td>
<td>
<telerik:RadComboBox ID="rcbStatus" runat="server"
Width="200px" DropDownAutoWidth="Enabled" OnDataBinding="rcbStatus_DataBinding"
AutoPostBack="false" CausesValidation="false">
</telerik:RadComboBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
HeaderText='Please correct the following error before proceed:'
ForeColor="Red" />
</td>
</tr>
<tr>
<td class="alignTop">
<asp:Button ID="btnUpdateTask" runat="server" ValidationGroup="ActivityValidation"
Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button>
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>
<asp:Label ID="lblMsg" runat="server" EnableViewState="false" ForeColor="red"></asp:Label>
</td>
<asp:HiddenField ID="hfContractId" runat="server" />
<asp:HiddenField ID="hfTaskId" runat="server" />
<asp:HiddenField ID="hfCurrentStatus" runat="server" />
</tr>
</table>
</div>
我认为问题出在btnUpdate
上,因为删除功能在两个页面上都可以正常工作。我对事件处理不太熟悉,因此非常感谢您提供有关此问题的任何帮助。