如何为asp.net中的每个项目添加复选框列表的工具提示
<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();
}
对于每个项目的工具提示都是不同的,对于管理工具提示是创建用户,对于用户工具提示是创建消息。如何为复选框内的每个项目添加工具提示
<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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用 ToolTip 属性:
这是您要问的吗?
如果您想更新每个项目的工具提示,那么您需要单独处理它们:
Use the ToolTip property:
Is this what you are asking?
If you want to update the ToolTip for each item then you need to treat them separately:
您可以使用 PreRender 事件——循环遍历项目(应该是 ListItems),并且可以根据复选框的值设置标题的 html 属性。
如果我想对复选框进行大量控制,我可能会倾向于在中继器中放置一个复选框 - 但这在这里可能没有必要。
You can use PreRender event-- loop over the items (should be ListItems), and you can set an html attribute for title based on the values of the checkbox.
In cases where I want to have alot of control over the checkboxes, I might favor putting a checkbox in a repeater-- but that might not be necessary here.
您可以在页面加载方法上编写以下代码片段:
chkbox.Items[0].Attributes.Add("标题", "管理员");
chkbox.ToolTip = "管理员";
chkbox.Items[1].Attributes.Add("标题", "用户");
chkbox.ToolTip = "用户";
You can write the following snippet of code on the page load method:
chkbox.Items[0].Attributes.Add("Title", "Admin");
chkbox.ToolTip = "Admin";
chkbox.Items[1].Attributes.Add("Title", "User");
chkbox.ToolTip = "User";
这就是我使用的,具有更多功能,例如使 ListItem 看起来像链接按钮。
因此,实际上,我根据 DatSource 中的数据放置了一个唯一的工具提示,并将 ListItem 的外观更改为蓝色下划线。
This is what I use, with more features, like making the ListItem look like a linkbutton.
So in effect I am placing a ToolTip that's unique based on the data from the DatSource and I change the appearance of the ListItem to blue underline.