2009-12-24 71 views
0

我已經在代碼隱藏文件中填充了asp.net datagrid。同時結合我已經使用DataGrid的onItemDataBound事件的onmouseover添加和onmouseout事件,看起來LIK這個..在datagrid mouseover和mouseout事件中的問題..在asp.net

保護無效dataGridSavedQueris_OnItemDataBound(對象發件人,DataGridItemEventArgs E) {

if (e.Item.ItemType == ListItemType.Item || 
     e.Item.ItemType == ListItemType.AlternatingItem) 
    { 
     e.Item.Attributes.Add("onmouseover", "dgRowHighlightOnWhenMouseOver(this,'" + e.Item.Cells[0].Text.ToString() + "');"); 
     e.Item.Attributes.Add("onmouseout", "dgRowHighlightOffWhenMouseOut (this,'" + e.Item.Cells[0].Text.ToString() + "');"); 
    }   
} 

現在,它呈現正常。我的意思是dgrowHighlightOnWhenMouseOver和dgRowHighlightOffWhenMouseOut被分配數據網格的每一行期望的頁眉和頁腳。

在onmouseover和onmouseout函數中,我顯示了div與關聯id的值。 每當我將一個單元格移動到同一行上的另一個單元格時,會發生什麼情況。

但是,我需要每當我​​鼠標懸停在該行未進行細胞火的兩個事件..

如何做到這一點?

感謝 R.E

+0

你的意思mouseout事件不觸發? – 2009-12-24 07:40:39

回答

0

你可能要附加的鼠標懸停/縮小RowCreated而不是的ItemDataBound。

事情是這樣的:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) 
{ 
    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
    e.Row.Attributes.Add("onmouseover", "dgRowHighlightOnWhenMouseOver(this,'" + e.Row.Cells[0].Text.ToString() + "');"); 
    e.Row.Attributes.Add("onmouseout", "dgRowHighlightOffWhenMouseOut(this,'" + e.Row.Cells[0].Text.ToString() + "');"); 
    } 
} 

PS:我沒有嘗試過了自己呢,所以我不能100%確定:P

+0

我只使用了Asp.Net DataGrid而不是GridView。儘管我已經使用GridView進行了測試。 但是,我得到了相同的結果... 謝謝 r.e – eswaran 2009-12-24 10:32:34

+0

啊,我錯過了DataGrid部分。不好意思,朋友。 – 2009-12-24 10:49:38

相關問題