tmhoang
asked on
DataGrid changes, combining multiple columns under one heading, adding text, adding mouse overs
I'd like help making a few changes to a typical datagrid. I haven't been able to search for tutorials for these changes, because I'm not exactly sure what to search for.
1. I'd like to combine three columns under one heading. For example, the heading should be called Description and the columns under it are grade, season, and year.
2. I'd like to add text in each cell along with the data from the database. For example, under one heading named 'Registration', the text should be 'starting date' with a date from one db column, and 'ending date' with a date from another db column.
3. I'd like to add a link column to the datagrid with an image that changes when the mouse goes over it.
4. I'd like to add a tooltip to the element that says something like 'click here to go to 'name'', with name being a value from the database.
I really appreciate any tips or links to some tutorials for these changes. Thanks.
1. I'd like to combine three columns under one heading. For example, the heading should be called Description and the columns under it are grade, season, and year.
2. I'd like to add text in each cell along with the data from the database. For example, under one heading named 'Registration', the text should be 'starting date' with a date from one db column, and 'ending date' with a date from another db column.
3. I'd like to add a link column to the datagrid with an image that changes when the mouse goes over it.
4. I'd like to add a tooltip to the element that says something like 'click here to go to 'name'', with name being a value from the database.
I really appreciate any tips or links to some tutorials for these changes. Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
I've already ask a similar question, follow the link:
https://www.experts-exchange.com/questions/21053919/DataGrid-Header-Group.html
I've already ask a similar question, follow the link:
https://www.experts-exchange.com/questions/21053919/DataGrid-Header-Group.html
ASKER
I found a solution for grouping columns under the heading by following the above links. Here's what I did:
public void dg_ItemCreated(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
e.Item.Cells[2].Text = "Organization Name";
e.Item.Cells[3].ColumnSpan = 2;
e.Item.Cells[3].Text = "Location";
e.Item.Cells.RemoveAt(4);
}
}
I'm now working on the other problems. I'll return later. Thanks everybody.
public void dg_ItemCreated(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
e.Item.Cells[2].Text = "Organization Name";
e.Item.Cells[3].ColumnSpan
e.Item.Cells[3].Text = "Location";
e.Item.Cells.RemoveAt(4);
}
}
I'm now working on the other problems. I'll return later. Thanks everybody.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<input type="hidden" name="__EVENTTARGET">
<input type="hidden" name="__EVENTARGUMENT">
<script language="javascript">
function __doPostBack(eventTarget, eventArgument)
{
var theform = document.Form1;
theform.__EVENTTARGET.valu
theform.__EVENTARGUMENT.va
theform.submit();
}
</script>
__________________________
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
BindGrid()
End If
end Sub
Private Sub DataGrid1_ItemCreated
(ByVal sender As Object,
ByVal e As DataGridItemEventArgs)
Handles DataGrid1.ItemCreated
If e.Item.ItemType = ListItemType.Item
Or e.Item.ItemType = ListItemType.AlternatingIt
Or e.Item.ItemType = ListItemType.SelectedItem Then
e.Item.Attributes.Add
("onmouseover", "this.style.backgroundColo
'beige';this.style.cursor=
e.Item.Attributes.Add
("onmouseout", "this.style.backgroundColo
e.Item.Attributes.Add
("onclick",
"javascript:__doPostBack
('" & "DataGrid1:" & "ctrl" &
e.Item.ItemIndex & ":ctrl0','')")
End If
End Sub
Private Sub DataGrid1_SelectedIndexCha
(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles DataGrid1.SelectedIndexCha
DataGrid1.SelectedItem.Att
"this.style.cursor='hand'"
DataGrid1.SelectedItem.Att
End sub
Regards,
Aeros