Access Rows of a datagrid

S

scott.loomis

I am not sure if this is the best place to post this.

I have an ASP.NET Datagrid control that I am using. I have been trying
to figure out if it is possible to select a row client side on page
load, i know about the datagrid selectedindex, but that does not
provide me with the functionality I am looking for. I have a
javascript function that catches a click event of the row

function onRowClick(row)
{
//Do something
}


Now that works fine if a user clicks on the datagrid, because my rows
reference the function <tr align="Center" onclick="onRowClick(this)">

I am looking for is a way to simulate a click on the first row on
page load via javascript.

My grid is named dgrList, here is the grid

<asp:datagrid id="dgrList" runat="server" Width="448px"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px"
BackColor="White" CellPadding="3" GridLines="Horizontal"
autogeneratecolumns="False">


Now when I try to run something like
onRowClick(document.frmRemoteScan.dgrList.rows(0));

I get the message that dgrList is null or not an object, and when I
loop throught the elements in my form, dgrList is not one of them(yes
it is between the form tags).

My question, is there a way to reference the created table via
javascipt? Or does anyone have a way to simulate the row clcik via
javascript
 
S

scott.loomis

I figured this out, and wanted to help anyone that might stumble on
this post

try document.getElementById('dgrList').rows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top