1:你可以直接在设计页面给Label的Text绑定到你要的字段
2:你可以在ItemDataBound里面e.Item.FindControl找到Label
然后给它赋值
protected void DataGrid1_ItemDataBound(Object sender,System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
string messageid = (string)e.Item.Cells[0].Text;
Label lab = (Label )e.Item.FindControl("Label1");
lab.Text="...";
}
}
foreach (DataGridItem item in this.DataGrid1.Items)
{
String strPiece=((TextBox)item.FindControl("edit_Piece")).Text.Trim().ToString();
TextBox TextBox1 = item.FindControl("TextBox1");
TextBox1.Text= Convert.ToInt32(strPiece)*33;
}