posts - 0,  comments - 20,  trackbacks - 0
private void ViewBinding()
        {    
            Expression<Func<TestTable, bool>> expr = n => GetCondition(n);
            var xQuery = DCDataContext.TestTables.Where<TestTable>(expr.Compile());
            this.dataGridView1.DataSource = xQuery.ToList<TestTable>();
        }
        private bool GetCondition(TestTable tb)
        {
            bool boolResult = true;
            if (txtUserNumber.Text.Trim() != string.Empty)
            {
                boolResult &= tb.UserNumber == int.Parse(txtUserNumber.Text.Trim());
            }
            if (txtName.Text.Trim() != string.Empty)
            {
                boolResult &= tb.Name == txtName.Text.Trim();
            }
            if (txtClassName.Text.Trim() != string.Empty)
            {
                boolResult &= tb.ClassName == txtClassName.Text.Trim();
            }
            return boolResult;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ViewBinding();
        }
posted on 2008-12-17 17:48 Documents 阅读(1888) 评论(0)  编辑  收藏 所属分类: LinqASP.NET

只有注册用户登录后才能发表评论。


网站导航:
 
<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

留言簿

文章分类

文章档案

J2EE

搜索

  •  

最新评论