Select Row by javascript in Datalist

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi misters,

I have Datalist like this:

....
<HeaderTemplate>
<table cellpadding="0" cellspacing="0" id="tbl"><tbody>
</HeaderTemplate>
<ItemTemplate>

<tr id="<%# "filaListado" + Eval("idtareasworkflow") %>"
onclick="SelectRow('<%# Eval("idtareasworkflow") %>', <%# "'" +
Eval("Offset") + "'" %>);"
<%# EstiloFilaJavaScript(Container) %>
class="<%# Container.ItemIndex % 2 == 0 ? "ItemStyle" :
"AlternatingItemStyle" %>"
....

Now, it want to access to Row of Item Template. I put attribute runat=server.

I can't bind to ID property if it's runat=server, isn't?

I have this code, now:

<tr id="rowDatalist"
runat="server"
onclick="SelectRow ????"

How I implement my javascript function SelectRow ? Which parameters of js
function ? I want to access to row, but the id of TR is dynamic, isn't? It
would be neccesary something like similar ClientID.

any help for me? I will be grateful for any comments, help...

Thanks in advance, regards, greetings.
 
Hi,
I think you are using wrong component to achieve your requirements. You are
trying to render html table at your own, but DataList also renders its
content to html table. That means result of your page will not be HTML valid.
It will look like:

<table>
<tr>
<td>
<!-- here will be your header template -->
<table cellpadding="0" cellspacing="0" id="tbl"><tbody>
</td>
</tr>
<tr>
<td>
<!-- here will be your first item -->
<td>
...
</td>
</td>
</tr>
etc.

If you want to control table rendering at your own you have to use Repeater
control.

Regards,
Ladislav
 
Back
Top