TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
william 0
NA
19
0
DataGrid ClientSideEvents
May 24 2004 10:46 PM
Sushila D. Patel - I converted the VB code snippet below to C# as seen in your article: http://www.c-sharpcorner.com/Code/2003/June/DataGridClientSideEvents.asp. It seemed to have worked okay except for the bad line below... This is the bad line: dv = dgContactHistory.DataSource; 'Cannot implicitly convert type 'object' to 'System.Data.DataView' dgContactHistory is a datagrid on my web form. The VB code seems to make this assignment without issue; I thought it would work in C#. I have tried to type-cast this line and it compiles, but the application doesn't like the (DataView) type-cast. Could anyone offer a suggestion? Thank you very much. William C# private void dgContactHistory_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { string strID; DataView dv; DataColumnCollection dc; dv = dgContactHistory.DataSource; dc = dv.Table.Columns; foreach (DataColumn dcCol in dv.Table.Columns) { if ((e.Item.ItemType == ListItemType.AlternatingItem) || (e.Item.ItemType == ListItemType.Item)) { strID = dgContactHistory.DataKeys[e.Item.ItemIndex].ToString(); e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#99ccff'"); ... VB Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _ ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound Dim dv As DataView = DataGrid1.DataSource Dim dcCol As DataColumn Dim dc As DataColumnCollection = dv.Table.Columns Dim strID As String For Each dcCol In dv.Table.Columns If e.Item.ItemType = ListItemType.AlternatingItem Or _ e.Item.ItemType = ListItemType.Item Then strID = DataGrid1.DataKeys(e.Item.ItemIndex) e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#99ccff'")
Reply
Answers (
1
)
.Net Architect needed for Internet marketing global leader - Full-time, Direct Hire in NC
asp.net dropdown does not hold any value