Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello
Using a listview control for the first time,i set a CommandName that will make the event
ListView_ItemCommand triggered when i click the Button but it's not.Nothing triggered when i click it
plz help


XML
<asp:ListView ID="ListView" runat="server" onitemcommand="ListView_ItemCommand"
              onitemediting="ListView_ItemEditing"
              onselectedindexchanged="ListView_SelectedIndexChanged">
              <EmptyDataTemplate>
                  <table runat="server"
                      style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                      <tr>
                          <td>
                              No data was returned.</td>
                      </tr>
                  </table>
              </EmptyDataTemplate>
              <ItemTemplate>
                  <tr style="background-color:#DCDCDC;color: #000000;">
                      <td style="text-align: center">
                          <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
                      </td>
                      <td style="text-align: center">
                          <asp:Label ID="BirthdayLabel" runat="server" Text='<%# Eval("Birthday") %>' />
                      </td>
                      <td style="text-align: center">
                          <asp:Label ID="CourseNameLabel" runat="server"
                              Text='<%# Eval("CourseName") %>' />
                      </td>

                      <td style="text-align: center">
                          <asp:ImageButton ID="Edit" runat="server" ImageUrl="~/images/edit_icon.png" CommandName="EhabEdit"  />
                      </td>
                       <td style="text-align: center">
                           <asp:ImageButton ID="Delete" runat="server" ImageUrl="~/images/delete_icon.png" CommandName="myDelete" CommandArgument="myDelete" />
                      </td>
                  </tr>
              </ItemTemplate>




C#
protected void ListView_ItemCommand(object sender, ListViewCommandEventArgs e)
      {
          if (e.CommandName == "EhabEdit")
          {
              Label1.Text = "Edit From Button";
          }
      }



plz help
Posted
Updated 16-Jan-12 17:30pm
v2
Comments
Rajesh Patil 1001 12-Aug-15 0:57am    
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1"
DataKeyNames="aminities_id" onitemcommand="ListView1_ItemCommand"
onprerender="ListView1_PreRender"
onselectedindexchanging="ListView1_SelectedIndexChanging">

<itemtemplate>
<%#Eval("aminities_id")%><br />
<%#Eval("aminities_type")%><br />
<%#Eval("crt_date")%><br />
<%#Eval("is_deleted")%><br />
<asp:Button ID="Button1" runat="server" Text="Button" CommandName="Add"/>

<SelectedItemTemplate>
<%#Eval("aminities_id")%>
<%#Eval("aminities_type")%>
<%#Eval("crt_date")%>
<%#Eval("is_deleted")%>
<asp:Button ID="btnShowModal" runat="server" Text="Button" CommandName="Add"/>
</SelectedItemTemplate>
Rajesh Patil 1001 12-Aug-15 0:58am    
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
{

}

not working when i click button...
please help me...

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