0

I have a datalist that displays images that I want to use as buttons, so I used the image button. But when I click the image, I get an error before it even gets to the if(e.CommandName == "imgButton") line. All I get is: 'System.Web.HttpUnhandledException' was thrown, I'm at a total loss. What am I doing wrong? Thanks

    <asp:DataList ID="dlImages" runat="server" RepeatDirection="Horizontal" RepeatColumns="3" OnItemCommand="dlImages_ItemCommand">
    <ItemTemplate>
    <asp:ImageButton ID="imgButton" runat="server" CommandName="imgButton"
    CommandArugment='<%# Eval("id")%>' 
    ImageUrl='<%# Eval("url")%>' Style="max-width: 200px" />
    </ItemTemplate> 
</asp:DataList>



protected void dlImages_ItemCommand(object source, DataListCommandEventArgs e)
           {
              if(e.CommandName == "imgButton")
               {
                  string taid = e.CommandArgument.ToString();
                  ShowModel(Toolkit.ToInt32(taid, 0));
                }
}

1 Answer 1

0

All I needed to do was to not bind my datalist on postback. And currently, something is very wrong with this page. Like I need 3D glasses to read it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.