Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, All

How to get command value to server side in repeater control

My Code:

ASP.NET
<ItemTemplate>
        <asp:Panel ID="pnl_tr" runat="server">
    <tr id="gh" align="center" style="removed: pointer"  önclick="Select('<%# Eval("UserIdN")%>');">
    <td><asp:CheckBox ID="chbxHT" runat="server"/></td>
    <td><asp:Label ID="lblEmpCode" runat="server" Text='<%#Eval("UserIdN")%>'></asp:Label></td>
    <td><asp:Label ID="Label1" runat="server" Text='<%#Eval("EmpCodeC")%>'></asp:Label></td>
    <td><asp:Label ID="Label2" runat="server" Text='<%#Eval("empnamec")%>'></asp:Label></td>
    <td><asp:Label ID="Label3" runat="server" Text='<%#Eval("deptcodec")%>'></asp:Label></td>
    <td><asp:Label ID="Label5" runat="server" Text='<%#Eval("seccodec")%>'></asp:Label></td>
    <td><asp:Label ID="Label6" runat="server" Text='<%#Eval("Dojd")%>'></asp:Label></td>
    <td><asp:Label ID="Label7" runat="server" Text='<%#Eval("NricWPNoC")%>'></asp:Label></td>
    <td><asp:Label ID="Label10" runat="server" Text='<%#Eval("ShiftGroupCodeC")%>'></asp:Label></td>
    <td><asp:Label ID="Label11" runat="server" Text='<%#Eval("LocationC")%>'></asp:Label></td>
    <td><asp:Label ID="Label12" runat="server" Text='<%#Eval("TerminateDateD")%>'></asp:Label></td>
    <td><asp:Label ID="Label13" runat="server" Text='<%#Eval("Gender")%>'></asp:Label></td>
    <td><asp:Label ID="Label14" runat="server" Text='<%#Eval("DOB")%>'></asp:Label></td>
    <td><asp:Label ID="Label15" runat="server" Text='<%#Eval("Privilege")%>'></asp:Label></td>
    <td><asp:Label ID="Label17" runat="server" Text='<%#Eval("Enabled")%>'></asp:Label></td>
    <td><asp:Label ID="Label18" runat="server" Text='<%#Eval("CardNumber")%>'></asp:Label></td>
        <asp:HiddenField ID="HiddenField1" runat="server" />
    </tr>
    </asp:Panel>
    </ItemTemplate>


When i try to use this itemcommand not fire...
Posted
Updated 20-Aug-14 21:07pm
v2

Hi,

I do not see any type of button inside your repeater control which can fire item command event.
Anyway refer below links or more on ItemCommand event

ItemCommand Event - MSDN[^]
Repeater Item Command Problem[^]

hope it helps.
 
Share this answer
 
Comments
prasanna.raj 21-Aug-14 3:22am    
How Can i get row value in repeater without any controls it possible.... in repeater...
Karthik Harve 21-Aug-14 3:29am    
I dont think so, because you need to place some server controls which will trigger the server side event.
prasanna.raj 21-Aug-14 5:13am    
Thanks...
in your aspx
C#
<asp:repeater id="Repeater1" runat="server" onitemcommand="Repeater1_ItemCommand">
<itemtemplate>

 <asp:button id="btnDetails" runat="server" text="Details" cssclass="aspxcontrolbuttons" commandname="Details" commandargument="<%# Eval("SomeValue") %>"></asp:button>
</itemtemplate>
</asp:repeater>


in your .cs

C#
public void Repeater1_ItemCommand(Object Sender, RepeaterCommandEventArgs e)
    {
        // check if the command name is close (if it's the button)
        if (e.CommandName == "Details")
        {
            string ID = (string)e.CommandArgument;
            //do something
        }
    }
 
Share this answer
 
v2
Comments
prasanna.raj 21-Aug-14 3:34am    
thanks...
Dilan Shaminda 21-Aug-14 3:44am    
you are welcome :-) please accept the answer if it helps you.

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