在VB的C/S结构的程序里,双击Grid里的某一行数据,可以将其值付给一个textbox的内容,请问在asp.net可以这样吗?

解决方案 »

  1.   

    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
      {
       if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem) || (e.Item.ItemType == ListItemType.SelectedItem) ) 
       {
        e.Item.Attributes.Add ("ondblclick", "js代码");
       }
      }
      

  2.   

    LoveCherry兄弟,能把js代码给我具体说一下吗?
    我是初学者,不太会!谢谢!!!
      

  3.   

    e.Item.Attributes.Add ("ondblclick", "alert('双击')");
      

  4.   

    js代码就是你想要的事件或者函数啊~
    比如e.Item.Attributes.Add ("ondblclick", "return confirm('你确认要删除本记录吗?')");
      

  5.   

    http://www.cnblogs.com/jhtchina/articles/115543.html
    我做過的,能實現妳的要求
      

  6.   

    非常感谢,能得到这么多兄弟的帮助我感觉非常高兴,大家说的在DataGrid里每一行所触发事件,有已经知道了,可是我还不会用js怎么实现在DataGrid里鼠标所在行的值,怎么付给一个textbox(我真是一个菜鸟呀)
      

  7.   

    if ((e.Item.ItemType==ListItemType.Item)||(e.Item.ItemType==ListItemType.AlternatingItem))
    {
    if (e.Item.Cells[21].Text=="退件")//加入是退件的話,改變揹景顔色
    {
    e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='red';this.style.color='yellow';this.style.cursor='default';");
    //e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.getAttribute('BKC');");
    e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='';this.style.color='';");
    }
    else
    {
    e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#ffffcc';this.style.color='buttontext';this.style.cursor='default';");
    //e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.getAttribute('BKC');");
    e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='';this.style.color='';");
    }testBox1.text=datagrid1.item.cell[0].text
    最后一句可以實現,應該
      

  8.   

    http://goody9807.611.cn/faq.aspx?pid=1
      

  9.   

    其实.net的东西真的都不难