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

- 中国WEB开发者网络 (http://www.webasp.net)
-- 技术教程 (http://www.webasp.net/article/)
--- [技巧]DataGird的hyper column的url field 绑定两个字段 (http://www.webasp.net/article/6/5198.htm)
-- 作者:未知
-- 发布日期: 2003-07-12
在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>";
    }
}


webasp.net