datagrid后台给每列添加js方法

protected void dgExhList_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            string param = "";
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView drv = (DataRowView)e.Item.DataItem;
                if (e.Item.ItemIndex >0)
                {
                    if (e.Item.Cells[1].Text == " ")
                    {
                        param = "";
                    }
                    else
                    {
                        param = e.Item.Cells[1].Text;
                    }
                    e.Item.Cells[2].Text = "<a href='#' onclick='ShowDetailInfo(\"" + param + "\")'>" + e.Item.Cells[2].Text + "</a>";
                }     
            }
        }

  

posted @ 2016-03-10 17:17  小爆脾气  阅读(168)  评论(0编辑  收藏  举报