我在DataGrid中读出了部门表中字段USERID,USERNAME,BUMEN中的数据,其中我想实现的是,当我把鼠标指到某个USERID号时,自动显示列出和某个USERID同部门的所职工名称,这个功能类似QQ的头像那样,当我把鼠标移到某个人的头像上就显示出他的昵称和号码?
解决问题就马上结分!!!!!高分求!!高分求!!!。。

解决方案 »

  1.   

    不太明白,什么叫某个USERID同部门的所职工名称.是所有职工名称??还是这个ID对应的职工的名称?
    用a标签的title属性.像这样<a title='职工名称:<%# DataBinder.Eval(Container.DataItem,"USERNAME") %>'></a>这样,当鼠标移动到这个a标签包含的字段上,就会显示这个提示.如果是列出这个部门的所有职工,可以在T-SQL语句中,读出每个部门的所有职工名,一起放入DataSet.
      

  2.   

    USERID -- 就是这个ID对应的职工的名称,我的意思是凡是和这个ID对应相同部门的职工都列出来,,
      

  3.   

    不错,楼上说得对,可以用超连接的Title来实现.
      

  4.   

    在查询是也查询出和USERID对应的字段.如USERWITH
    使用模板列:
    <asp:Label Runat="server" style="CURSOR: hand" ToolTip='<%# DataBinder.Eval(Container.DataItem,"USERWITH")%>'><%# DataBinder.Eval(Container.DataItem,"USERID")%>
    </asp:Label>
      

  5.   

    e.Item.Cells[0].Attributes.Add("title","同部门的人员名单");
      

  6.   

    有些控件有个AlternateText属性!
    AlternateText = "aa";
    就会出现你要的效果!!
      

  7.   

    当DataGrid读出了所有数据,那还要多加载一次才能实现的吧,,,就是说把鼠标移到任何一个USERID时,就马上加载检索与该ID所对应的所有相同部门的职工的名称。然后才显示出来。。对吧
      

  8.   

    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
    {
    //this.title可以显示多个列
    e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#AAAADD';this.style.cursor='hand';this.title='"+e.Item.Cells[1].Text+e.Item.Cells[2].Text+"'");
    e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");

    }
    }
      

  9.   

    用ToolTip<asp:Label Runat="server" style="CURSOR: hand" ToolTip='<%# DataBinder.Eval(Container.DataItem,"USERWITH")%>'><%# DataBinder.Eval(Container.DataItem,"USERID")%>
    </asp:Label>
      

  10.   

    你上面那位兄弟说的
    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
    {
    //this.title可以显示多个列
    e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#AAAADD';this.style.cursor='hand';this.title='"+e.Item.Cells[1].Text+e.Item.Cells[2].Text+"'");
    e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");}
    }这样作连接不行的
      

  11.   

    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
    {
    //this.title可以显示多个列
    //e.Item.Cells[1].Text和e.Item.Cells[2].Text是隐藏列。
    e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#AAAADD';this.style.cursor='hand';this.title='类型:"+e.Item.Cells[1].Text+"  大小:"+e.Item.Cells[2].Text+"'");
    e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");}
    }
      

  12.   

    用datagrid的relation属性,将两个表关联就行
      

  13.   

    这样如何在
    this.title='类型:"+e.Item.Cells[1].Text+"  大小:"+e.Item.Cells[2].Text+"'");
    里添加连接呢?