Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Imports System.Data
Imports System.Data.OleDb
Imports System.IO
Imports System.Drawing 
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim imag As New ImageButton
        For Each tr As TableRow In Table2.Rows
            For Each tc As TableCell In tr.Cells
                For Each c As Control In tc.Controls
                    If Not c.[GetType]() Is GetType(ImageButton) Then
                        tc.Controls.Add(imag)
                        imag.ImageUrl = "~/pic/flower.jpg"
                        imag.ID = Session("imgtle")
                        imag.OnClientClick = "SetSource(this.Id)"
                    End If
                Next
            Next
        Next
    End Sub
Posted
Updated 28-Mar-14 0:24am
v3
Comments
Wombaticus 28-Mar-14 6:53am    
"For Each c As Control In tc.Controls"
If there are no controls in the cell, then this loop won't execute - might that that be teh case?
Member 10599753 28-Mar-14 7:57am    
sir, then I set one image button in first cell.but it didn't work.My purpose is , to add one image button in the next empty cell only.
Wombaticus 28-Mar-14 6:55am    
Also, you should declare the imag without "new" at the top, then set = new on each loop

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900