开发者

How to bind tooltip on datagrid rows?

开发者 https://www.devze.com 2023-04-02 04:44 出处:网络
I\'m trying to bind datagrid rows with tooltip. In which event should i write the code? The row created event doesnt hold my data to bind and returning blank. The code reference is given below:

I'm trying to bind datagrid rows with tooltip. In which event should i write the code? The row created event doesnt hold my data to bind and returning blank. The code reference is given below:

 protected void gdvAct开发者_运维技巧ionItemView_RowCreated(object sender, GridViewRowEventArgs e)
    {


        e.Row.Cells[2].ToolTip = e.Row.Cells[2].Text;
        if (e.Row.Cells[2].Text.Length > 100)
        {
            e.Row.Cells[2].Text.Substring(0, 100);
        }


    }

Please help.


You can right Row Databound event such as:

protected void grdUserClone_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            for (int colIndex = 0; colIndex < e.Row.Cells.Count; colIndex++)
            {
                e.Row.Cells[colIndex].Attributes.Add("title", e.Row.Cells[colIndex].Text);
            }
        }
    }


Found the answer. It should be written under RowDataBound.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号