Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.††If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 10th, 2005, 12:27 PM
Registered User
 
Join Date: Feb 2005
Location: Willimantic, Connecticut, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting DataGrid Cell Data

Im working on a client with mouseover controls on a DataGrid to make life easier on a user who is very perticular as to how he wants to do things. However i cant pull the Data out of the Cell. I tried pulling it from the DataTable, but when the grid is resorted by the user the DataTable is not, and thus when the data i am pulling is incorrect. Is there a way to work around this? Im working in C# but i can read any .NET Language...
Reply With Quote
  #2 (permalink)  
Old February 20th, 2005, 01:43 PM
Registered User
 
Join Date: Feb 2005
Location: Tampa, FL, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just did this the other day, to reformat a column in the datagrid. In it, I overloaded the data binding method of the datagrid so that I could display a link depending on the content of the cell. Hope it gives you an idea of how to access it.


Protected Sub myDataGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles myDataGrid.ItemDataBound
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
   If (e.Item.Cells(column_typeID).Text = "fldr") Then
      e.Item.Cells(column_fileID).Text = "<a href='ScreenFolders.aspx?objid=" + e.Item.Cells(column_fileID).Text + "' target='_blank'>View Folder</a>"
   ElseIf (e.Item.Cells(column_typeID).Text = "file") Then

      e.Item.Cells(column_fileID).Text = "<a href='Screenfiles.aspx?objid=" + e.Item.Cells(column_fileID).Text + "' target='_blank'>View File</a>"
      End If
   End If
End Sub
Reply With Quote
  #3 (permalink)  
Old February 20th, 2005, 07:00 PM
Registered User
 
Join Date: Feb 2005
Location: Willimantic, Connecticut, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thats nice code... However im working with WinForms and the WinForm DataGrid. i Did however fix the problem.
C#
Code:
  BindingManagerBase bm = 
    ((System.Windows.Forms.DataGrid)sender).BindingContext[ 
      ((System.Windows.Forms.DataGrid)sender).DataSource, 
      ((System.Windows.Forms.DataGrid)sender).DataMember]; 
  DataRow dr = ((DataRowView)(bm.Current)).Row;
VB (Converted by hand from C#, hope its 100% correct.)
Code:
  Dim bm As BindingManagerBase = 
    CType(sender, System.Windows.Forms.DataGrid).BindingContext( 
      CType(sender, System.Windows.Forms.DataGrid).DataSource, 
      CType(sender, System.Windows.Forms.DataGrid).DataMember) 
  Dim dr As DataRow = CType(bm.Current, DataRowView).Row
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blink Datagrid cell data?? vinodjangle ASP.NET 2.0 Professional 1 April 18th, 2008 10:51 AM
Copy data into cell by cell zone Excel VBA 2 September 4th, 2007 12:50 PM
Can't read new data from DataGrid cell Guest00 ASP.NET 1.0 and 1.1 Basics 3 October 18th, 2004 12:51 AM
DataGrid Cell mrideout BOOK: Beginning ASP.NET 1.0 0 August 17th, 2004 01:34 PM
How to add data to a DataGrid Cell. chiefouko VS.NET 2002/2003 2 July 28th, 2004 02:24 AM



All times are GMT -4. The time now is 09:58 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.