我有一個基本的1表網格。我有一個叫分支類型的字段。分行類型只能是企業或特許經營。當我點擊ASPxgridview行上的編輯按鈕時,我想顯示並隱藏編輯表單上的字段,具體取決於它的分支類型。所以如果是公司,我想顯示經理字段和隱藏所有者字段。當分支類型是特許經營時,我希望顯示所有者字段並將管理員字段隱藏在編輯表單上。所有細節都可以在網格視圖中顯示,但在編輯表單上我想強制用戶只填寫適用的字段。ASPxGridview undefined
如果你看看下面:
這基本上就是我想要實現的加載編輯表單:
protected void ASPxGridViewStores_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e)
{
if (!ASPxGridViewStores.IsEditing || e.Column.FieldName != "StoreOwnershipID") return;
if(e.KeyValue == DBNull.Value || e.KeyValue == null) return;
object val = ASPxGridViewStores.GetRowValuesByKeyValue(e.KeyValue, "S_ID");
if(val == DBNull.Value) return;
int StoreOwnershipID = (Int32)val;
if (StoreOwnershipID == 4)
{ ASPxComboBox ManagerID = (ASPxComboBox)ASPxGridViewStores.FindEditFormTemplateControl("ManagerID");
ManagerID.Enabled = true;
ASPxComboBox ContactID = (ASPxComboBox)ASPxGridViewStores.FindEditFormTemplateControl("ContactID");
ManagerID.Enabled = true;
}
else
{ ASPxComboBox ManagerID = (ASPxComboBox)ASPxGridViewStores.FindEditFormTemplateControl("ManagerID");
ManagerID.Enabled = false;
ASPxComboBox ContactID = (ASPxComboBox)ASPxGridViewStores.FindEditFormTemplateControl("ContactID");
ManagerID.Enabled = false;
}
}
,然後根據在「StoreOwnershipID」現場我會選擇企業或加盟使用客戶端腳本來啓用或禁用其他字段。
我做了一些研究,以及,我想出了下面的代碼:
SelectedIndexChanged="function(s, e) {
var value = s.GetValue();
if(value == 4)
GridViewStores.GetEditor("OwnerName").SetVisible(true);
else
GridViewStores.GetEditor("OwnerName").SetVisible(false);
}"
但是當這個叫我收到以下錯誤:
微軟JScript運行時錯誤:「GridViewStores 「未定義
我已經添加在web.config中的HttpHandler:
<httpModules>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</httpModules>
和
<system.webServer>
<modules>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</modules>
,你可以看到下面我插入ClientInstanceName,
我已經從自動識別改變的ClientIDMode以繼承爲靜態可預測的和每個方案不起作用,仍然renderes:Microsoft JScript中的運行時錯誤:'ASPxGridview'未定義。
我的gridview的標籤下面
<dx:ASPxGridView ID="ASPxGridView" runat="server" AutoGenerateColumns="False"
ClientIDMode="Predictable" DataSourceID="SqlDataSource1" KeyFieldName="S_ID"
ClientInstanceName="ASPxGridView">
我現在甚至試圖創建一個只有一個SqlDataSource和GridView用的storetype字段acombobox一個新的頁面,包括JavaScript作爲我在以前的文章中提到..並沒有一切都好運。我已經給你我的web.config設置,我宣佈了httphandler,那麼你還有什麼建議我做這個工作?
這裏是我的webconfig:
部分使使用 ASP.NET來識別傳入的用戶的安全身份驗證模式的配置 。 - > 部分啓用配置 如果/在執行請求期間發生未處理的錯誤 時該怎麼辦。具體而言, 它使開發人員能夠配置html錯誤頁面 以代替錯誤堆棧跟蹤進行顯示。
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<httpModules>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</httpModules>
<httpHandlers>
<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET" path="DX.ashx" validate="false" />
</httpHandlers>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
遺憾的looong問題。順便說一句,這是使用DevExpress Gridview。從DevExpress的傢伙不能幫助我和德1天回答一個問題,所以它已經持續了現在將近一個星期......
謝謝 沃納