문제

I need to add a tooltip to a TemplateField in a GridView, but only to Row that meets some condition. How can I achieve that?

도움이 되었습니까?

해결책

   protected void GridView1_DataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // check for condition 
            if (e.Row.Cells[0].Text.Contains("sometext"))
            {
                 e.Row.ToolTip = "Text to be shown on mouseover of the row";
            }
        }
    }

다른 팁

Use the row databound which will hit each row as it is created. Then inside use .findcontrol to get whatever control it is that you are adding a tooltip to.

Then assign the tooltip.

Wrap this in whatever condition you want to use.

If you post your current code then I may be able to help further.

try this, This event through you can check your all gridview rows.

gridview row event Name is =OnRowDataBound : "GridView1_RowDataBound"

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        //Add Your Condition here
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top