Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid Select Row ItemCommand

Status
Not open for further replies.

vblou

Programmer
Sep 17, 2002
9
US
Hi

The 1st column on my datagrid contains a link button that fires the ItemCommand and select the row when it's clicked. What I want to do now is, instead of having to click on the link button, I want to be able to click any where on the row itself and do the same thing. I want to change the 1st column to just a regular text column. Thanks in advance.

vblou
 
keep the link button in the 1st column since you have the server code in place. then use a js library like jquery to alter the table. something like
Code:
$(function {
   $("#[table id] tr").each(function{
      var link = this.child("td.first a");
      this.click(function{
           document.location = link.attr("href");
      };
      link.replaceWith(link.text());
   });
});
which will transform
Code:
<table id=...">
  <tr>
     <th>header 1</th>
     <th>header 1</th>
  <tr>
  <tr>
     <td><a href="form.aspx?id=1#">A<a/></td>
     <td>B</td>
  <tr>
  <tr>
     <td><a href="form.aspx?id=2">C<a/></td>
     <td>D</td>
  <tr>
</table>
into (it doesn't actually add an onclick attribute. that's just for visualization)
Code:
<table id=...">
  <tr>
     <th>header 1</th>
     <th>header 1</th>
  <tr>
  <tr onclick="go to form.aspx?id=1">
     <td>A</td>
     <td>B</td>
  <tr>
  <tr onclick="go to form.aspx?id=2">
     <td>C</td>
     <td>D</td>
  <tr>
</table>
for more help use th js and jquery form (google groups)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top