如何添加工具提示的CheckBoxList在asp.net每个项目 [英] How to add tooltip for Checkboxlist for each item in asp.net

查看:144
本文介绍了如何添加工具提示的CheckBoxList在asp.net每个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < ASP:的CheckBoxList ID =ckl_EditRoleDataValueField =角色名=服务器>
                                    < / ASP:&的CheckBoxList GT;
公共无效BindListBoxPermission(INT场)
    {
        MySqlCommand的命令=新的MySqlCommand();
        DataSet的DS =新的DataSet();
        INT newOrgID =领域;
        字符串MysqlStatement =1 ORDER BY角色ID降序从tbl_Role当角色ID&GT选择角色名称;
        了MySQLParameter [] =参数新了MySQLParameter [0];
        DS = server.ExecuteQuery(CommandType.Text,MysqlStatement,参数);
        ckl_EditRole.DataSource = DS;
        ckl_EditRole.DataBind();
    }

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


解决方案

 保护无效Page_ preRender(对象发件人,EventArgs的发送)
{
    的foreach(在ckl_EditRole.Items列表项的项目)
    {
        item.Attributes [标题] = GetRoleTooltip(item.Value);
    }
}私人静态字符串GetRoleTooltip(串P)
{
    //这里是你的code根据角色来获得相应的提示信息
}

<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();
    }

For each item tooltip is different, for admin tooltip is creates user and for users tooltip is creates message. How can I add tooltip for each item inside the check box

解决方案

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
}

这篇关于如何添加工具提示的CheckBoxList在asp.net每个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆