2012-05-04 28 views

回答

1

你可以嘗試這樣的事情,首先你要進口System.Collection.Generic命名空間

private List<string> addContent(string content) 
{ 
    //create a generic list of string type 
    List<string> s = new List<string>(); 

    for (int i = 0; i < 10; i++) 
    { 
     s.Add(content); 
    } 
    return s; 
} 

protected void btnAdd_Click(object sender, EventArgs e) 
{ 
    //Passed the List<> as DataSource and then bind the content in the list<> in the DataGrid 
    this.DataGrid1.DataSource = this.addContent(this.txtadd.Text); 
    this.DataGrid1.DataBind(); 

} 

我希望這對你的作品

相關問題