Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Conrad Evans   on Apr 19 In Asp.net Category.

  
Question Answered By: Erin Dunn   on Apr 19

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.

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on LinkButton Or get search suggestion and latest updates.


Tagged: