[英]ASP devexpress How to filter gridview by combobox selected item
[英]How to Call/access control combobox asp devexpress
我想在我的gridview中調用我的組合框以函數btnShow_Click
,但是當我在C#中鍵入組合框的ID時,當前上下文中不存在名稱對象。
對於信息,我的gridview有3個數據源,而我的組合框我想設置3個數據源(1個gridview有3個條件數據源,有3個條件組合框數據源)
protected void btnShow_Click(object sender, EventArgs e)
{
string ddl = ddlApp.Value.ToString();
if (ddl == "ATTD")
{
GvMenu.DataSourceID = "SqlDataSourceAttd";
GvMenu.DataBind();
}
else if (ddl == "TRVL")
{
GvMenu.DataSourceID = "SqlDataSourceTrvl";
GvMenu.DataBind();
}
else if (ddl == "CORE")
{
GvMenu.DataSourceID = "SqlDataSourceCore";
GvMenu.DataBind();
}
}
在aspx gridview中
[![我的網格視圖的代碼段] [1]] [1]
<dx:GridviewDataComboboxcolumn FieldName="ParentMenuID" visibleindex="2" Caption="Parent Menu ID" showincustomizationform="true" >
<PropertiesComboBox ValueField="ParentMenuID" TextField="ParentMenuID" ValueType="System.String" >
</PropertiesComboBox>
</dx:GridviewDataComboboxcolumn>
您應該使用ASPxGridView.FindRowCellTemplateControl方法查找位於列的DataItemTemplate容器中的控件。 另請參閱模板中包含的訪問控件主題。
自定義控件的最佳位置是Init和Load事件,這些事件應用於控件初始化:Init和Load。
使用Init / Load事件處理程序的一般技術
請參考以下內容:
在ASPxGridView列的DataItem模板中查找控件
如何在服務器端使用C#在OnCustomButtonCallback事件中查找DataItemTemplate控件
ASPxGridView-如何在DataItem模板中查找控件
要在運行時更改網格的數據源:
ASPxGridView-如何更改網格的數據源
ASPxGridView-如何在運行時更改數據源
ASPxGridView-如何動態更改數據源
如何在運行時動態切換網格的數據源並重新創建列
請從我們的代碼中心查看如何在運行時動態切換網格的數據源並在運行時重新創建列的示例,該示例演示了如何在運行時切換數據源。 我建議您查看此示例中提到的其他示例。
我注意到您在單元格模板中僅使用ASPxComboBox和ASPxLabel組件。 您可以使用GridViewDataComboBoxColumn獲得相同的結果。
<dx:GridViewDataComboBoxColumn FieldName="ParentMenuID">
<PropertiesComboBox ValueType="System.String" />
</dx:GridViewDataComboBoxColumn>
if (ddl == "ATTD")
{
var parentMenuColumn = (GridViewDataComboBoxColumn)GvMenu.Columns["ParentMenuID"];
parentMenuColumn.PropertiesComboBox.DataSourceID = "Your Data Source ID";
GvMenu.DataSourceID = "SqlDataSourceAttd";
GvMenu.DataBind();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.