I have a repeater. i want to get empid when i click on its any row.? how can i ?
My code is:-
<table id="table1" class="yui" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>
<a href='#' title="Click Header to Sort">Emp name #</a>
</th>
<th>
<a href='#' title="Click Header to Sort">emp sal</a>
</th>
<th>
<a href='#' title="Click Header to Sort">emp address</a>
</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="Repaddressorbbl" runat="server" OnItemCommand="Repaddressorbbl_ItemCommand">
<ItemTemplate>
<tr id="gh" style="cursor: pointer" onclick="Select(this);">
<td style="text-align: center;">
<%#Eval("empname")%>
</td>
<td style="text-align: center;">
<%# Eval("empsal")%>
</td>
<td style="text-align: center;">
<%# Eval("empadd")%>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
<tfoot>
<tr id="pagerOne1">
<td colspan="4">
<img src="_assets/img/first.png" class="first" />
<img src="_assets/img/prev.png" class="prev" />
<input type="text" class="pagedisplay" />
<img src="_assets/img/next.png" class="next" />
<img src="_assets/img/last.png" class="last" />
<select class="pagesize">
<option selected="selected" value="100">100</option>
<option value="200">200</option>
<option value="400">400</option>
</select>
</td>
</tr>
</tfoot>
</table>
YOu have to create manual postback. But for this to work always, your repeater should bind always, i.e. during each postback.
The following code snippets may guide you.
The aspx markup looks like this:
I’ve used an ObjectDataSource which returns a string array of names, but the choice of datasource is entirely yours. Here I’ve used just for e.g. sake.
Note that I am calling Repeater1.Databind() on Page_Load irrespective of postback or not. There are probably better ways to do this. But most of the code came exactly here