c# - ASP.NET TableCell OnSelected? -


so, have create list of items database, , gridview; however, client requires while select item list, automatically displays item's picture elsewhere.

so, created table, , create rows code behind fill it.

this table:

<asp:table id="tblwatches" cssclass="table table-striped" runat="server" width="50%" borderstyle="double" bordercolor="black">     <asp:tablerow id="tablerow1" runat="server">         <asp:tablecell id="tblcell1">             <asp:label id="code" runat="server" text="code"></asp:label>                         </asp:tablecell>          <asp:tablecell id="tblcell2">             <asp:label id="stock" runat="server" text="stock"></asp:label>                         </asp:tablecell>          <asp:tablecell id="tblcell3">             <asp:label id="purchased" runat="server" text="purchased"></asp:label>                         </asp:tablecell>          <asp:tablecell id="tblcell4">             <asp:label id="price" runat="server" text="price"></asp:label>                         </asp:tablecell>     </asp:tablerow> </asp:table>  

on code behind, create rows this:

dataview view; view = getwatches();  tablerow rownew; tablecell cellnew; label lblnew;   (int = 0; < view.count; i++) {            rownew = new tablerow();     tblwatches.rows.add(rownew);      cellnew = new tablecell();                 lblnew = new label();     lblnew.text = convert.tostring(view[i][1]);     cellnew.tabindex = convert.toint16(i + 1);       cellnew.controls.add(lblnew);     rownew.cells.add(cellnew);       cellnew = new tablecell();     lblnew = new label();     lblnew.text = convert.toint32(view[i][2]).tostring();        cellnew.controls.add(lblnew);     rownew.cells.add(cellnew);       cellnew = new tablecell();     lblnew = new label();     lblnew.text = convert.tostring(view[i][3]);      cellnew.controls.add(lblnew);     rownew.cells.add(cellnew);      cellnew = new tablecell();     lblnew = new label();     lblnew.text = convert.tostring(view[i][4]);      cellnew.controls.add(lblnew);     rownew.cells.add(cellnew); } 

that works perfectly. created rows, , can cycle through them tab key. thing is, want able use "onselect" event, when client cycles through items, image box updated. tablecell doesn't have event. there workaround? @ possible?

p.s.: why tab-cycling? want list feel excel spreadsheet, can move through items arrow keys. closest i've managed tabindex.

the tablecell type mentioned has no onselected event, easiest option tackle in front-end jquery binding on focus event table cells:

$(function() {     $("table[id$=tblwatches] tr td").on( "focus", function() {         var code = $(this).parent("tr").find("td:first-child > label").text();         // set img src here     }); }); 

then depending on image files stored, use product code set src path on <img>. i.e. "/images/products/" + code + ".jpg" or handler "/productimage.ashx?code=" + code


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -