|
Study this, this is what I copied in a program (I have not used it, but the effect is what you want), it should be helpful to you.
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//
// Used to display relevant test data
//
if(e.Item.ItemType==ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.SelectedItem)
{
string _strDiv = "javascript:showmenu(event,\"<Font size=9px><Table cellSpacing=0 cellPadding=1 width=100% border=1 border=0><tr style=BORDER-BOTTOM: #808080 1px solid> ";
for (int i = 1 ;i <e.Item.Cells.Count-2;i++)
{
if (DataGrid1.Columns[i].Visible != false)
{
_strDiv +="<td width=100px class=TD1>";
_strDiv += DataGrid1.Columns[i].HeaderText.ToString()+" </td>";
_strDiv += "<td width=40px class=TD1>" + e.Item.Cells[i].Text + " </td>";
if ((i% 3) == 0&&i != 0&&i != e.Item.Cells.Count-2)
{
_strDiv += "</tr><tr>";
}
else
{
if (i == e.Item.Cells.Count-2) // how is the last item
{
if ((i% 3) == 0) //
{
_strDiv += "</tr>";
}
else
{
for (int ii = 1 ;ii<=3-(i%3);ii++)
{
_strDiv +="<td class=TD1> </td><td class=TD1> </td>";
}
_strDiv += "</tr>";
}
}
}
}
}
_strDiv += "</table></Font>\")";
e.Item.Attributes.Add("onmouseover",_strDiv);
}
} |
|