select row on click

Results 1 to 2 of 2

Thread: select row on click

  1. #1
    Join Date
    Dec 1969

    Default select row on click

    &nbsp;<BR>i have simple datagrid (only bound columns) and i want to <BR><BR>select the row on click <BR><BR>give any idea to do<BR><BR>thanks in advance<BR><BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default javascript

    Here&#039;s an quick and dirty implementation I used a couple of years ago...<BR><BR>You should be able to add the onclick event to each DataGrid row in the Datagrid_ItemDataBound event.<BR><BR>&lt;html&gt;<BR>&lt;head&gt;<BR>&lt; style type="text/css"&gt;<BR> .selectedRow {<BR> background-color: silver;<BR> font-weight: bold;<BR> }<BR>&lt;/style&gt;<BR>&lt;script language="javascript"&gt;<BR> function selectRow(elm){<BR> var otherTRs = document.getElementsByTagName("tr");<BR> for(var i = 0;i &lt; otherTRs.length;i++){<BR> if(otherTRs[i].className == "selectedRow"){<BR> otherTRs[i].className = "";<BR> }<BR> }<BR> elm.className="selectedRow";<BR> }<BR>&lt;/script&gt;<BR>&lt;/head&gt;<BR>&lt;body&gt;<BR>&lt;table&gt;<BR> &lt;tr onclick="selectRow(this);"&gt;<BR> &lt;td&gt;Cell 1, Row 1&lt;/td&gt;<BR> &lt;td&gt;Cell 2, Row 1&lt;/td&gt;<BR> &lt;/tr&gt;<BR> &lt;tr onclick="selectRow(this);"&gt;<BR> &lt;td&gt;Cell 1, Row 2&lt;/td&gt;<BR> &lt;td&gt;Cell 2, Row 2&lt;/td&gt;<BR> &lt;/tr&gt;<BR>&lt;/table&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts