Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
sir. i have create a Datatable at runtime and bind with gridview. i want to add a image in datatable then bind with gridview. My code for example is there:-

Dim table As New DataTable
VB
table.Columns.Add("Teacher", GetType(String))
       table.Columns.Add("Course", GetType(String))


table = GetTable(Teacher, Course)
VB
GridView1.DataSource = table
      GridView1.DataBind()
      table.Dispose()





SQL
Public Function GetTable(ByVal Teacher As String, ByVal Course As String, ByVal Subject As String, ByVal Sem As String) As DataTable

cmd.commandtext="select * from Teacher"
     table.Rows.Add(Teacher, Course)

       Return table

   End Function



how can i add i image in new column in datatable and then bind with gridview?
Posted

this might help you..

Display-Images-in-GridView-Control[^]
 
Share this answer
 
In ASP.NET GrideView you can define your columns as you wish - one of the options is ImageFiled...
Check this tutorial on how to do this - http://msdn.microsoft.com/en-us/library/aa479350.aspx[^]
 
Share this answer
 
Comments
TCS54321 22-Oct-14 3:05am    
Number of Image Column are not fix. And name of image column are also not fix.
TCS54321 22-Oct-14 3:05am    
its increase and decrease as situation.
Kornfeld Eliyahu Peter 22-Oct-14 3:09am    
You can create the columns from code behind too, not only from mark-up!

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