cn.Close(); return CList; }
public bool EditCData(CData c) {
SqlConnection cn = new
SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings[\
SqlCommand cmd = new SqlCommand(\text=@text where id=@id\
cmd.Parameters.Add(\
System.Data.SqlDbType.NVarChar).Value = c.text; cmd.Parameters.Add(\System.Data.SqlDbType.Int).Value=c.id; cn.Open();
int r = cmd.ExecuteNonQuery(); cn.Close(); if (r > 0)
return true; else
return false; } }
在数据库 创建一个表 随便取名
xaml代码
HorizontalAlignment=\Width=\RowEditEnded=\ \
private void dataGrid1_RowEditEnded(object sender, DataGridRowEditEndedEventArgs e) {
CData c = e.Row.DataContext as CData; Service1Client s = new Service1Client(); s.EditCDataCompleted += new
EventHandler
void s_EditCDataCompleted(object sender, EditCDataCompletedEventArgs e) {
if (e.Result)
System.Windows.Browser.HtmlPage.Window.Alert(\成功\ else
System.Windows.Browser.HtmlPage.Window.Alert(\失败\ }
然后测试 显示列表后 双击一个行
然后点击DataGrid边框 结束编辑状态
Silverlight DataGrid使用之三 排序篇 2011-06-06 23:18
首先DataGrid 自带的排序特性
HorizontalAlignment=\Width=\RowEditEnded=\ 另一个方法是使用 System.Windows.Data.PagedCollectionView 在后台代码 public partial class DataGridControl : UserControl { public DataGridControl() { InitializeComponent(); SilverlightApplication1.ServiceReference1.Service1Client c = new ServiceReference1.Service1Client(); c.GetCDatasCompleted += new EventHandler c.GetCDatasAsync(); } void c_GetCDatasCompleted(object sender, ServiceReference1.GetCDatasCompletedEventArgs e) { if (e.Error == null) { System.Windows.Data.PagedCollectionView view = new System.Windows.Data.PagedCollectionView(e.Result); view.SortDescriptions.Add(new System.ComponentModel.SortDescription(\ System.ComponentModel.ListSortDirection.Descending) );//指定属性名称作排序 dataGrid1.ItemsSource = view; } } Silverlight DataGrid使用之四 过滤篇 2011-06-06 23:36 创建wcf和xml页面 参考 http://hi.http://www.wodefanwen.com//mldark/blog/item/a8f40a1909fa26a34bedbce3.html http://hi.http://www.wodefanwen.com//mldark/blog/item/a8315d01c4c3b909738b650d.html 然后在后台代码 修改一下 namespace SilverlightApplication1 { public partial class DataGridControl : UserControl {