日期:2014-05-20 浏览次数:20832 次
var data1 = form1.Text; Func<string, bool> Filter = x => x.Length == 3 && new int[] {x[0],x[1],x[2]}.Max().Any(y => data1.Contains(y.ToString()));
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) bind("7,8,9".Split(',')); } private void bind(string[] stringarray) { int i = 0, j = 0; List<string> str = new List<string>(); for (i = 0; i < 1000; i++) { string str_temp = ""; if (i < 10) str_temp = "00"; else if (i < 100) str_temp = "0"; str.Add(str_temp + i.ToString()); } var source1 = from t in str where select_string(t, stringarray) select t; DataTable dt = new DataTable(); for (i = 1; i <= 10; i++) dt.Columns.Add("列" + i.ToString(), typeof(string)); i = 0; j = 0; dt.Rows.Add(); foreach (var t in source1) { if (j >= 10) { dt.Rows.Add(); i++; j = 0; } dt.Rows[i][j] = t; j++; } GridView1.DataSource = dt; GridView1.DataBind(); } private bool select_string(string str, string[] stringarray) { char str_char = str[0]; for (int i = 1; i < str.Length; i++) { str_char = str_char < str[i] ? str[i] : str_char; } if (stringarray.Contains(str_char.ToString())) return true; return false; }