【发布时间】:2010-10-16 20:06:37
【问题描述】:
我有一个包含所有国家/地区的下拉框(ddlCountry),如果我选择美国,它将显示网格 显示与美国相关的税务信息。如果我编辑信息 在网格中,如果我们在下拉框中将国家美国更改为英国 在 ddlCountry(不是网格编辑窗口中的下拉框,没问题)它显示错误,如
指定的参数超出了有效值的范围。 参数名称:ItemHierarchicalIndex 说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.ArgumentOutOfRangeException:指定的参数超出了有效值的范围。 参数名称:ItemHierarchicalIndex
来源错误:
第 86 行:} 第 87 行: 第 88 行:如果(rgStateTax.EditItems.Count > 0) 第 89 行:{ 第 90 行:foreach( rgStateTax.Items 中的 GridDataItem 项)
源文件:c:\Projects\ACS\sample.Acs.Administration\UserControls\TaxManager.ascx.cs 行:88
堆栈跟踪:
[ArgumentOutOfRangeException:指定的参数超出了有效值的范围。 参数名称:ItemHierarchicalIndex] Telerik.WebControls.GridItemCollection.get_Item(字符串分级索引)+323 Telerik.WebControls.GridDataItemCollection.get_Item(字符串分级索引)+37 Telerik.WebControls.RadGrid.get_EditItems() +215 c:\Projects\ACS\sample.Acs.Administration\UserControls\TaxManager.ascx.cs:88 中的 sample.Acs.Administration.TaxManager.rgStateTax_PreRender(Object sender, EventArgs e) System.Web.UI.Control.OnPreRender(EventArgs e) +8682870 System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +31 Telerik.RadGridUtils.RadControl.OnPreRender(EventArgs e) +36 Telerik.RadGridUtils.RadAJAXControl.OnPreRender(EventArgs e) +37 Telerik.WebControls.RadGrid.OnPreRender(EventArgs e) +40 System.Web.UI.Control.PreRenderRecursiveInternal() +80 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
这是 grid(rgstatetax) 预渲染事件
protected void rgStateTax_PreRender( object sender, EventArgs e )
{
if( rgStateTax.MasterTableView.IsItemInserted )
{
foreach( GridItem item in rgStateTax.Items )
{
item.Visible = false;
}
}
if( rgStateTax.EditItems.Count > 0 )
{
foreach( GridDataItem item in rgStateTax.Items )
{
if( item != rgStateTax.EditItems[0] )
{
item.Visible = false;
}
}
}
用户界面中的代码
protected void ddlCountryTax_SelectedIndexChanged(对象发送者,EventArgs e) { long locationId = ddlCountryTax.SelectedItem.Value.AsLong();
ContentAdministrationServiceClient client = null;
List<DCTaxRate> taxRate = null;
try
{
client = new ContentAdministrationServiceClient();
taxRate = client.GetTaxRatesByCountryIdAndLocationTypeName( locationId, "State" );
client.Close();
}
catch( FaultException )
{
AbortClient(client);
throw;
}
rgStateTax.DataSource = taxRate;
rgStateTax.Rebind();
}
包装层中的代码
公共列表 GetTaxRatesByCountryIdAndLocationTypeName(long countryId, string locationTypeName) { DCTaxRateCollection taxRates = new DCTaxRateCollection(); taxRates.GetByCountryIdAndLoactionTypeName( countryId, locationTypeName );
return taxRates.ToList();
}
public void GetByCountryIdAndLoactionTypeName( long countryId, string locationTypeName )
{
IBOTaxRateCollection iboTaxRates = new BOTaxRateCollection();
iboTaxRates.GetByCountryIdAndLocationTypeName( countryId, locationTypeName );
SetItems( iboTaxRates );
}
在博层
public void GetByCountryIdAndLocationTypeName( long countryId, string locationTypeName )
{
ISingleResult<TaxRate> taxRates = Database.TaxRateReadByCountryIdAndLocationTypeName( countryId, locationTypeName );
PopulateCollection( taxRates );
}
【问题讨论】: