datalist数据绑定时发生的事件

    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataRowView item = (DataRowView)e.Item.DataItem;
            LinkButton hl = (Label)e.Item.FindControl("LinkButton1");
            if (item["member_name"].ToString().Length > 5)
            {
                hl.Text = item["e_name"].ToString().Substring(0, 5) + "...";
            }
            else
            {
                hl.Text = item["e_name"].ToString();
            }
        }
    }

你可能感兴趣的:(object)