1

I have a webform that contains a listview like this:

<asp:ListView ID="SlidesListView" runat="server" OnItemCommand="SlidesListView_ItemCommand">
                <LayoutTemplate>
                    <span runat="server" id="itemPlaceholder" style="display: inline-block" />
                </LayoutTemplate>
                <ItemTemplate>
                    <div class="SlideDiv">
                        <div>
                            <asp:ImageButton ID="ChangeDescriptionImageButton" runat="server" ImageUrl="~/Image/Change.png" CommandArgument="<%# Eval("ID") %>" CommandName="Change" AlternateText="Change" ToolTip="Change" />
                            <asp:Image ID="Image1" runat="server" CssClass="MiniSliderPic" ImageUrl='<%#Eval("ImagePath") %>' AlternateText='<%#Eval("Description") %>' ToolTip='<%#Eval("Description") %>' />
                            <p><%#Eval("Description").ToString().Replace(Environment.NewLine, "<br/>").Replace("\n", "<br />") %></p>
                        </div>
                    </div>
                    </span>
                </ItemTemplate>

            </asp:ListView>

and codebehind:

protected void SlidesListView_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        int ID = 0;
        switch (e.CommandName)
        {
            case "Change":
                ID = Convert.ToInt32(e.CommandArgument.ToString());
              break;

} }

but when I try to open this webform , I face this error:

An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. the server tag is not well formed

and asp:ImageButton tag get red.why?

Masoumeh Karvar
  • 791
  • 1
  • 14
  • 32

1 Answers1

1

Change this:

CommandArgument="<%# Eval("ID") %>"

To this:

 CommandArgument='<%# Eval("ID") %>'

BTW, I don't think you can use imagebutton this way. It will fire it's won OnCommand rather than ListView's ItemCommand. Consider using a linkbutton with image inside it.

<asp:LinkButton ID="ChangeDescriptionLinkButton" runat="server"
    CommandName="Change"
    CommandArgument='<%# Eval("ID") %>' >
    <img src="~/Image/Change.png" alt="Change" />Change
</asp:LinkButton> 
afzalulh
  • 7,925
  • 2
  • 26
  • 37