Change gridview field type

  • Thread starter Thread starter monzer ahmed
  • Start date Start date
M

monzer ahmed

Guest
I'm a newbie in vb.net ! my code working to show my database data on GridView it's work fine but I want to change specific value to Image? my code :

Dim img_c As String = "my image Url"
Dim img_x As String
Dim constr As String = ("my connection string")
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand()
cmd.CommandText = "SELECT * FROM Attendance"
cmd.Connection = con
Dim sda As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
sda.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
Dim ds As New DataSet
For i As Integer = 1 To GridView1.Rows.Count - 2
For s As Integer = 3 To GridView1.Columns.Count - 2
If GridView1.Rows(i).Cells(s).text ="1" Then
GridView1.ImageField(img_c)

End If
Next
Next

my source:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="std_num"
Height="448px" Width="1352px" BackColor="White" BorderColor="#3366CC"
BorderStyle="None" BorderWidth="1px" style="margin-right: 12px">
<Columns>
<asp:BoundField DataField="Total" HeaderText="totla" SortExpression="Total" >
<HeaderStyle ForeColor="White" />
</asp:BoundField>
<asp:BoundField DataField="4" HeaderText="4" SortExpression="4" >
<HeaderStyle ForeColor="White" />
</asp:BoundField>
<asp:BoundField DataField="3" HeaderText="3" SortExpression="3" >
<HeaderStyle ForeColor="White" />
</asp:BoundField>
<asp:BoundField DataField="2" HeaderText="2" SortExpression="2" >
<HeaderStyle ForeColor="White" />
</asp:BoundField>
<asp:BoundField DataField="1" HeaderText="1" SortExpression="1" >
<HeaderStyle ForeColor="White" />
</asp:BoundField>
<asp:BoundField DataField="std_name" HeaderText="std_name"
SortExpression="std_name" >
<HeaderStyle ForeColor="White" />
</asp:BoundField>
<asp:BoundField DataField="std_num" HeaderText="std_num"
SortExpression="std_num" ReadOnly="True" >
<HeaderStyle ForeColor="White" />
</asp:BoundField>
<asp:BoundField DataField="No" HeaderText="No" SortExpression="No"
InsertVisible="False" ReadOnly="True" >
<HeaderStyle ForeColor="White" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<RowStyle BackColor="White" ForeColor="Black" BorderColor="#333333"
Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<SortedAscendingCellStyle BackColor="#EDF6F6" />
<SortedAscendingHeaderStyle BackColor="#0D4AC4" />
<SortedDescendingCellStyle BackColor="#D6DFDF" />
<SortedDescendingHeaderStyle BackColor="#002876" />
</asp:GridView>

my issue is change field to Image , there is no GridView image properties

Continue reading...
 
Back
Top