如何为asp.net中的每个项目添加Checkboxlist的工具提示

Mar*_*ark 8 c# asp.net tooltip checkboxlist

<asp:CheckBoxList ID="ckl_EditRole" DataValueField="RoleName" runat="server">
                                    </asp:CheckBoxList>
public void BindListBoxPermission(int field)
    {
        MySqlCommand command = new MySqlCommand();
        DataSet ds = new DataSet();
        int newOrgID = field;
        string MysqlStatement = "SELECT RoleName from tbl_Role Where RoleID >1 order by RoleID desc";
        MySqlParameter[] param = new MySqlParameter[0];
        ds = server.ExecuteQuery(CommandType.Text, MysqlStatement, param);
        ckl_EditRole.DataSource = ds;
        ckl_EditRole.DataBind();
    }
Run Code Online (Sandbox Code Playgroud)

对于每个项目,工具提示是不同的,因为管理工具提示是创建用户而对于用户工具提示是创建消息.如何为复选框内的每个项添加工具提示

Yur*_*kiy 15

protected void Page_PreRender(object sender, EventArgs e)
{
    foreach (ListItem item in ckl_EditRole.Items)
    {
        item.Attributes["title"] = GetRoleTooltip(item.Value);
    }
}

private static string GetRoleTooltip(string p)
{
    // here is your code to get appropriate tooltip message depending on role
}
Run Code Online (Sandbox Code Playgroud)