Jump to content

How to get the contents of DataGrid control?


Recommended Posts

Hi,

Can anyone help me to get the contents of Datagrid object?

Is it possible to get the contents of Datagrid object using AutoIt?

Thanks a lot ^.^

<{POST_SNAPBACK}>

You didn't really provide enough context for your question, but I'll take a guess that you mean a rendered ASP.Net datagrid on a webpage. If this is not correct, and in the future, please provide more information about what you are trying to do.

An ASP.Net datagrid renders as a standard table in HTML and the Document Object Model can be used to parse it. Using the AutoIt beta with COM support and the IE Automation UDF Library you can do the following:

#include <IE.au3>

$oIE = _IECreate()
_IENavigate($oIE, "http://samples.gotdotnet.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datagrid/VB/datagrid1.aspx")
$oTable = _IETableGetObjByIndex($oIE, 0)
$aDataArray = _IETableWriteToArray($oTable)

For $r = 0 to 9
    For $c = 0 to 4
        ConsoleWrite($aDataArray[$c][$r] & @TAB)
    Next
    ConsoleWrite(@CR)
Next

This returns:

IntegerValue    StringValue DateTimeValue   BoolValue   CurrencyValue   
1   Item 1  7/18/2005 6:10:00 AM    True    2.46    
2   Item 2  7/18/2005 6:10:00 AM    False   3.69    
3   Item 3  7/18/2005 6:10:00 AM    True    4.92    
4   Item 4  7/18/2005 6:10:00 AM    False   6.15    
5   Item 5  7/18/2005 6:10:00 AM    True    7.38    
6   Item 6  7/18/2005 6:10:00 AM    False   8.61    
7   Item 7  7/18/2005 6:10:00 AM    True    9.84    
8   Item 8  7/18/2005 6:10:00 AM    False   11.07   
9   Item 9  7/18/2005 6:10:00 AM    True    12.3

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...