Click here to Skip to main content
15,914,222 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
ASP.NET
<div>
                        <ul class="ul-Clinical" style="margin-removed 5px;">
                            <asp:Repeater ID="rptAllMembers" runat="server">
                                <ItemTemplate>
                                    <li class="ul_Clinical_li1" style="margin-removed 10px; margin-removed 15px; border: 1px solid #ccc;
                                        width: 100px; height: 100px;"  önclick="clickshowtick('<%# Eval("TherapistStaffID") %>')">
                                        <div id='<%# Eval("TherapistStaffID") %>' class="">
                                        </div>
                                        <img src="../images/Avatar.png" alt="TimeSheet" style="width: 50px;" /><br />
                                        <asp:Label ID="lblUsername" runat="server" ToolTip='<%# Eval("FirstName") + " " + Eval("LastName") %>'
                                            Text='<%# Eval("FirstName") + " " + Eval("LastName") %>'></asp:Label>
                                    </li>
                                </ItemTemplate>
                            </asp:Repeater>
                        </ul>
                    </div>


This is my for repeater i am implementing the tick class on it of jquery.and getting id from my table.in eval id='<%# Eval("TherapistStaffID") %>'

ASP.NET
<div class="DivGeneral">
                                <asp:Label ID="lblSearch" runat="server" Text="Search:" Width="50px"></asp:Label>
                                <asp:TextBox ID="txtSearch" runat="server" CssClass="sf" Width="423px">
                                </asp:TextBox>
                                <%--Hidden Field--%>
                                <asp:HiddenField ID="hfSelectedMembeID" runat="server" Value="" />
                            </div>


this my hidden field in which i want to put my repeater id.

JavaScript
function clickshowtick(tckclass) {

            if ($('#' + tckclass).hasClass("tick_img"))
                $('#' + tckclass).removeClass("tick_img");
            else
                $('#' + tckclass).addClass("tick_img");
            $("#<%=hfSelectedMembeID.ClientID %>").val(tckclass);

            var str;
            str = $("#<%=hfSelectedMembeID.ClientID %>").val(tckclass) + ',' + tckclass }


this is my javascript code at the top of my design class.

here is a problem that i dont know how to get the id from repeater link button on click.and after that how to put it in hidden field

and after that how can i get it at code behind.
at last how to store it in database.

please help me.

thxxxxxxxxxxxxxxxxxxxx
Posted
Updated 4-Dec-19 23:33pm

Hi,

So your problem is you cant get any unique identification while user click or any other operation on that particular row.

You can achieve it using several way, but don't use hidden fields its not a secure.

before binding you can bind your auto generated id with that grid view but that column should be invisible.

Or

you can directly bind DB identity filed to that grid.

Or

Create one GUID for each row and on click asynchronously send that GUID to sever and depending on that check your data. put that GUID to a custom attribute of TR and you can get it via JQuery or javascript * recommended

Or

if your table is not sort able then you will get row index in javascript and that row index is equals to your datatables row index at server. send that index to server. (IF you not using paging) * Not recommended
 
Share this answer
 
v2
Repeater Code :
ASP.NET
<td><span runat="server" id="lbBranchname" style="font-style:italic;"><%# Eval("branchname")%></span>
    </td>

Code behind : rptBranch_ItemCommand
C#
HtmlGenericControl lbBranchname = e.Item.FindControl("lbBranchname") as HtmlGenericControl;
    BranchName = lbBranchname.InnerText;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900