[技巧]DataGird的hyper column的url field 绑定两个字段

发表于:2007-07-01来源:作者:点击数: 标签:
在ItemDataBound事件里做

//假设第一列为超级链接列
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
    string ID = "123";
    string Name = "user";
    if ( ( e.Item.ItemType != ListItemType.Header ) && ( e.Item.ItemType != ListItemType.Footer ) )
    {
        e.Item.Cells[0].Text = "<a href=" + ( ( HyperLink ) e.Item.Cells[0].Controls[0] ).NavigateUrl + "&ID=" + ID + "&Name=" + Name + ">" + ( ( HyperLink ) e.Item.Cells[0].Controls[0] ).Text + "</a>";
    }
}

原文转自:http://www.ltesting.net