JPByD 0 Newbie Poster

I am an intermediate web designer and am working on my first backend page. I have a working editor and just need to add the ability to insert photos into the editor. I have dynamically displayed the images in a modal popup window and just need to add a click event to the imagebuttons... but, I keep getting build errors - it wants a method or my code is incorrect. All of the examples I have found aren't working.

My code is below... any help would be appreciated!:)

public void PopulateImages(DataSet ids)
    { 
        //Populates dataset to table
        DataTable dt = ids.Tables[0];
        DataRow dr;

        Table tbl = new Table();
        TableRow tRow = new TableRow();
        TableCell tCell = new TableCell();        
        
        int cntRow = dt.Rows.Count;
        //tbl.Rows.Add(tRow);  
        int i;
        for (i=0; i <= cntRow-1; i++)
        {
            dr = dt.Rows[i];
            // Adds row for every 2 images
            if (i % 2 == 0)
            {
                tbl.Rows.Add(tRow);              
            }


            tRow.Cells.Add(tCell);
            
            //Create Imagebutton
            ImageButton myButton = new ImageButton();
            string myFileName = dr["FileName"].ToString();
            string myFileDescription = dr["PhotoDescription"].ToString();
            myButton.ImageUrl = "~/PhotosSm/" + myFileName;
            myButton.AlternateText = "~/PhotosSm/" + dr["FileName"].ToString();
            myButton.Width = 150;
//            myButton.Click += <%# ImageInsert_Click(myFileName,myFileDescription)%>;
//            myButton.Click += new ImageClickEventHandler(ImageInsert_Click(myFileName,myFileDescription));
//            myButton.Click += new EventHandler(ImageInsert_Click(myFileName, myFileDescription));
//            myButton.OnClientClick = <%= ImageInsert_Click(myFileName,myFileDescription)%>;
            
                      
            tCell.Controls.Add(myButton);

            //Create matching text
            Label myLabel = new Label();
            myLabel.Text = myFileDescription;
            tCell.Controls.Add(myLabel);
        }
        //Put table in panel
        ImageTablePane.Controls.Add(tbl);  
   }
    protected void ImageInsert_Click(string MyFileName, string myFileDescription)
    {
        string imgText = string.Format("<img src='{0}' alt='{1}'>", 
            MyFileName, myFileDescription);
        Editor1.Content = imgText + Editor1.Content;
    
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.