<asp:ButtonField ButtonType="Image" DataTextField="BookID" ImageUrl="~\images\{0}.png" />
ImageUrl=<%#"~\images\"+eval("bookID")+".png"
ImageUrl='<%# Eval("bookID", "~/images/{0}.png") %>'
CommandArgument
<asp:ImageButton ... CommandArgument='<%# Eval("bookID") %>' .../>
sender
IButtonControl
Command
CommandEventArgs
<asp:ImageButton ID="IBKutub" ImageUrl='<%# Eval("bookID", "~/images/{0}.png") %>' runat="server" Height="120px" Width="90px" CommandArgument='<%# Eval("bookID") %>' />
protected void GVBooks_RowDataBound(object sender, GridViewRowEventArgs e) { if (sender.Equals("IBKutub")) { Response.Redirect("BookDetails.aspx"); } }
RowDataBound
GridView
Click
ImageButton
<asp:ImageButton ID="IBKutub" runat="server" ImageUrl='<%# Eval("bookID", "~/images/{0}.png") %>' CommandArgument='<%# Eval("bookID") %>' OnClick="IBKutub_Click"/>
protected void IBKutub_Click(object sender, EventArgs e){ var button = sender as IButtonControl; string bookID = (button == null) ? null : button.CommandArgument; // Do something with the ID here...}
string bookID = (button == null) ? null : button.CommandArgument;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)