Frankb
11-24-2004, 12:52 PM
Hello I am struggeling with an error when trying to verify a image files existance before binding it to a datagrid.
The error message I am recieving on the if statement is
BC30311: Value of type 'System.Data.DataRowCollection' cannot be converted to 'String'.
I don't see why its trying to convert to a string.
here is the code.
Sub BindGrid()
Dim DS As DataSet
Dim MyCommand As oledbDataAdapter
MyCommand = new oledbDataAdapter("select * from mytable", MyConnection)
DS = new DataSet()
MyCommand.Fill(DS, "mytable")
dim i as integer
for i=0 to DS.Tables("mytable").Rows.Count-1
IF(System.IO.File.Exists(Server.MapPath(DS.Tables("mytable").Rows[i]["picture"])))Then
'picture available
Else
DS.Tables("mytable").Rows[i]["picture"]="images/none.jpg"
end if
Next
MyDataGrid.DataSource=DS.Tables("mytable").DefaultView
MyDataGrid.DataBind()
End Sub
and datagrid image section
<asp:Image id=Image1 runat="server" NAME="Image1" Height = 75 Width =100 ImageUrl='<%# DataBinder.Eval(Container.DataItem, "picture") %>'>
any help is greatly appreciated.
Thanks
The error message I am recieving on the if statement is
BC30311: Value of type 'System.Data.DataRowCollection' cannot be converted to 'String'.
I don't see why its trying to convert to a string.
here is the code.
Sub BindGrid()
Dim DS As DataSet
Dim MyCommand As oledbDataAdapter
MyCommand = new oledbDataAdapter("select * from mytable", MyConnection)
DS = new DataSet()
MyCommand.Fill(DS, "mytable")
dim i as integer
for i=0 to DS.Tables("mytable").Rows.Count-1
IF(System.IO.File.Exists(Server.MapPath(DS.Tables("mytable").Rows[i]["picture"])))Then
'picture available
Else
DS.Tables("mytable").Rows[i]["picture"]="images/none.jpg"
end if
Next
MyDataGrid.DataSource=DS.Tables("mytable").DefaultView
MyDataGrid.DataBind()
End Sub
and datagrid image section
<asp:Image id=Image1 runat="server" NAME="Image1" Height = 75 Width =100 ImageUrl='<%# DataBinder.Eval(Container.DataItem, "picture") %>'>
any help is greatly appreciated.
Thanks