Here is some C# code which dynamically generates ImageButtons
and uses values from an OLeDbDatareader:
imageItem = new System.Web.UI.WebControls.ImageButton();
imageItem.ImageUrl = "CM/Links/LinkImages/" + dr.GetString(3);
imageItem.ID = dr.GetInt32(0).ToString();
imageItem.Command += new CommandEventHandler(ImageButton_Command);
imageItem.CommandName = dr.GetInt32(0).ToString();
private void ImageButton_Command(object sender, CommandEventArgs e)
{
string Sql = "INSERT INTO LinkManagementItems " +
"(ClickDate, ClickThroughs, LinkManagementID) " +
"VALUES ('" + DateTime.Now + "', " + 1 + ", " +
Convert.ToInt32(e.CommandName) + ")";
try
{
DBUtility.ExecuteSQLCommand(Sql);
}
catch (Exception exc)
{
Response.Write(exc.Message.ToString());
}
}
If I had more time I'd flesh it out for you, but this should give you a bit of
help.