惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 司徒正美
Google Online Security Blog
Google Online Security Blog
博客园_首页
量子位
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
The Cloudflare Blog
Vercel News
Vercel News
GbyAI
GbyAI
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cisco Blogs
IT之家
IT之家
A
Arctic Wolf
P
Privacy International News Feed
G
GRAHAM CLULEY
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
The Blog of Author Tim Ferriss
AWS News Blog
AWS News Blog
A
About on SuperTechFans
P
Proofpoint News Feed
I
Intezer
月光博客
月光博客
Cloudbric
Cloudbric
Google DeepMind News
Google DeepMind News
T
Tor Project blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Securelist
Engineering at Meta
Engineering at Meta
爱范儿
爱范儿
F
Full Disclosure
V2EX - 技术
V2EX - 技术
Last Week in AI
Last Week in AI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
人人都是产品经理
人人都是产品经理
C
Check Point Blog
I
InfoQ
S
Security Affairs
Simon Willison's Weblog
Simon Willison's Weblog
P
Palo Alto Networks Blog
F
Fortinet All Blogs
S
Security @ Cisco Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
K
Kaspersky official blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security

博客园 - sunrack

LINQ to SQL语句之Group By/Having和Exists/In/Any/All/Contains ASPxPopupControl does not show up in the right place C++/CLI托管字符串与非托管char数组的转换 程序员从初级到中级10个秘诀 Get JavaScript IntelliSense With DevExpress Client-Side Objects - v2010 vol 1 ASPxRadioButtonList 报错解决办法 - sunrack - 博客园 本地连接属性“出现意外错误”的解决办法 - sunrack - 博客园 Bootstrap DotNetFX35SP1 in Visual Studio 2010 Windows Server 2008 共享策略 XtraPivotGrid Custom Summaries 手动注册 DevExpress 8.2.3 控件到 Visual Studio 工具箱 sn.exe error "Failed to generate a strong name key pair -- The keyset is not defined" Thread Tools Rate Thread 浅析JavaScript中的showModalDialog的实战应用 javascript showModalDialog模态对话框使用说明 - sunrack - 博客园 entity framework 缓存干扰的数据不一致问题 Failed to load viewstate ? Typical problem, with an obvious solution. ViewState and Dynamic Control ASPxGridView 和 AJAX Extensions ToolBox 不兼容 ASPxCombobox Features
Grid Editing - Cascading Combo Boxes - sunrack
sunrack · 2010-12-09 · via 博客园 - sunrack

<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="CascadingComboBoxes.aspx.cs"
Inherits="GridEditing_CascadingComboBoxes" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHolder" runat="Server">
<script type="text/javascript">
// <![CDATA[
function OnCountryChanged(cmbCountry) {
grid.GetEditor("City").PerformCallback(cmbCountry.GetValue().toString());
}
// ]]>
</script>
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="AccessDataSourceMain"
KeyFieldName="CustomerID" Width="100%" AutoGenerateColumns="False" OnCellEditorInitialize="grid_CellEditorInitialize">
<Settings ShowGroupPanel="True" />
<SettingsEditing Mode="Inline" />
<Columns>
<dx:GridViewCommandColumn VisibleIndex="0">
<EditButton Visible="True">
</EditButton>
</dx:GridViewCommandColumn>
<dx:GridViewDataComboBoxColumn FieldName="Country" VisibleIndex="1">
<PropertiesComboBox TextField="Country" ValueField="Country" EnableSynchronization="False"
IncrementalFilteringMode="StartsWith" DataSourceID="AccessDataSourceCountry">
<ClientSideEvents SelectedIndexChanged="function(s, e) { OnCountryChanged(s); }"></ClientSideEvents>
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
<dx:GridViewDataComboBoxColumn FieldName="City" VisibleIndex="2">
<PropertiesComboBox EnableSynchronization="False" IncrementalFilteringMode="StartsWith"
DropDownStyle="DropDown">
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
<dx:GridViewDataColumn VisibleIndex="3" FieldName="ContactName">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn VisibleIndex="4" FieldName="CompanyName">
</dx:GridViewDataColumn>
</Columns>
</dx:ASPxGridView>
<asp:AccessDataSource ID="AccessDataSourceMain" runat="server" DataFile="~/App_Data/nwind.mdb"
OnDeleting="AccessDataSource1_Modifying" OnInserting="AccessDataSource1_Modifying"
OnUpdating="AccessDataSource1_Modifying" SelectCommand="SELECT * FROM [Customers]"
DeleteCommand="DELETE FROM [Customers] WHERE [CustomerID] = ?" InsertCommand="INSERT INTO [Customers] ([CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode], [Country], [Phone], [Fax]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
UpdateCommand="UPDATE [Customers] SET [CompanyName] = ?, [ContactName] = ?, [City] = ?, [Country] = ? WHERE [CustomerID] = ?">
<DeleteParameters>
<asp:Parameter Name="CustomerID" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="CompanyName" Type="String" />
<asp:Parameter Name="ContactName" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Country" Type="String" />
</UpdateParameters>
</asp:AccessDataSource>
<asp:AccessDataSource ID="AccessDataSourceCountry" runat="server" DataFile="~/App_Data/WorldCities.mdb"
SelectCommand="SELECT * FROM [Countries]"></asp:AccessDataSource>
<asp:AccessDataSource ID="AccessDataSourceCities" runat="server" DataFile="~/App_Data/WorldCities.mdb"
SelectCommand="SELECT c.City FROM [Cities] c, [Countries] cr WHERE (c.CountryId = cr.CountryId) AND (cr.Country = ?) order by c.City">
<SelectParameters>
<asp:Parameter Name="?" />
</SelectParameters>
</asp:AccessDataSource>
</asp:Content>

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.Web.ASPxCallbackPanel;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxClasses;
using DevExpress.Web.Demos;
public partial class GridEditing_CascadingComboBoxes : Page {
protected void Page_Load(object sender, EventArgs e) {
if(!IsPostBack) {
grid.StartEdit(3);
}
}
protected void grid_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e) {
if(!grid.IsEditing || e.Column.FieldName != "City") return;
if(e.KeyValue == DBNull.Value || e.KeyValue == null) return;
object val = grid.GetRowValuesByKeyValue(e.KeyValue, "Country");
if(val == DBNull.Value) return;
string country = (string)val;
ASPxComboBox combo = e.Editor as ASPxComboBox;
FillCityCombo(combo, country);
combo.Callback += new CallbackEventHandlerBase(cmbCity_OnCallback);
}
protected void FillCityCombo(ASPxComboBox cmb, string country) {
if (string.IsNullOrEmpty(country)) return;
List<string> cities = GetCities(country);
cmb.Items.Clear();
foreach (string city in cities)
cmb.Items.Add(city);
}
List<string> GetCities(string country) {
List<string> list = new List<string>();
AccessDataSourceCities.SelectParameters[0].DefaultValue = country;
DataView view = (DataView)AccessDataSourceCities.Select(DataSourceSelectArguments.Empty);
for(int i = 0; i < view.Count; i++) {
list.Add((string)view[i][0]);
}
return list;
}
protected void AccessDataSource1_Modifying(object sender, SqlDataSourceCommandEventArgs e) {
Utils.AssertNotReadOnly();
}
void cmbCity_OnCallback(object source, CallbackEventArgsBase e) {
FillCityCombo(source as ASPxComboBox, e.Parameter);
}
}

http://demos.devexpress.com/ASPxGridViewDemos/GridEditing/CascadingComboBoxes.aspx