1、模板列只有编辑时候能找到 2、 /// <summary> /// To get the DataGrid control value /// </summary> /// <param name="Row">A zero based row number .</param> /// <param name="ColumnID">Control Id in DataGrid .</param> /// <returns>String</returns> public string GetItemString( int Row,string ColumnID ) { if ( Row > this.Items.Count ) return ""; DataGridItem dgItem = this.Items[Row]; // Try to find & deal with each control. for(int i=0;i<dgItem.Cells.Count;i++) { for(int j=0;j<dgItem.Cells[i].Controls.Count;j++) { Control ctrl = dgItem.Cells[i].Controls[j]; if ( ctrl.ID == ColumnID && ctrl is TextBox ) return (( TextBox )ctrl).Text; if ( ctrl.ID == ColumnID && ctrl is Label ) return (( Label )ctrl).Text; } } return ""; }
2、 /// <summary>
/// To get the DataGrid control value
/// </summary>
/// <param name="Row">A zero based row number .</param>
/// <param name="ColumnID">Control Id in DataGrid .</param>
/// <returns>String</returns>
public string GetItemString( int Row,string ColumnID )
{
if ( Row > this.Items.Count ) return "";
DataGridItem dgItem = this.Items[Row]; // Try to find & deal with each control.
for(int i=0;i<dgItem.Cells.Count;i++)
{
for(int j=0;j<dgItem.Cells[i].Controls.Count;j++)
{
Control ctrl = dgItem.Cells[i].Controls[j];
if ( ctrl.ID == ColumnID && ctrl is TextBox ) return (( TextBox )ctrl).Text;
if ( ctrl.ID == ColumnID && ctrl is Label ) return (( Label )ctrl).Text;
}
}
return "";
}