Neal Hartman
asked on
RowDataBound
In a Gridview I have a column with a Templetfield that has an imaige of a floppy disk. In the RowDataBound event I have e.Row.Cells(0).Attributes. Add(.... stuff.
What I would like to do is, if the file to be downloaded does not exists, change the image to something else.
What I would like to do is, if the file to be downloaded does not exists, change the image to something else.
in RowDataBound Event
for each row check if file exist then change image to exist, and if file doean't exist change the image to other
for each row check if file exist then change image to exist, and if file doean't exist change the image to other
ASKER
I meant: How do I change the ImageURL in the Templatefield from the RowdataBound Sub?
CType(e.Row.Cells(0).Contr
ASKER
System.ArgumentOutOfRangeE xception was unhandled by user code
Message="Specified argument was out of the range of valid values.
Parameter name: index"
ParamName="index"
Source="System.Web"
StackTrace:
at System.Web.UI.ControlColle ction.get_ Item(Int32 index)
at ResultsMain.gvDownloadsTop _RowDataBo und(Object sender, GridViewRowEventArgs e) in C:\VB\VBSOURCE\Visual Studio 2005\WebSites\EM2000Net\re sults.aspx .vb:line 1530
at System.Web.UI.WebControls. GridView.O nRowDataBo und(GridVi ewRowEvent Args e)
at System.Web.UI.WebControls. GridView.C reateRow(I nt32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource)
at System.Web.UI.WebControls. GridView.C reateChild Controls(I Enumerable dataSource, Boolean dataBinding)
at System.Web.UI.WebControls. CompositeD ataBoundCo ntrol.Perf ormDataBin ding(IEnum erable data)
at System.Web.UI.WebControls. GridView.P erformData Binding(IE numerable data)
at System.Web.UI.WebControls. DataBoundC ontrol.OnD ataSourceV iewSelectC allback(IE numerable data)
at System.Web.UI.DataSourceVi ew.Select( DataSource SelectArgu ments arguments, DataSourceViewSelectCallba ck callback)
at System.Web.UI.WebControls. DataBoundC ontrol.Per formSelect ()
at System.Web.UI.WebControls. BaseDataBo undControl .DataBind( )
at System.Web.UI.WebControls. GridView.D ataBind()
at ResultsMain.Page_Load(Obje ct sender, EventArgs e) in C:\VB\VBSOURCE\Visual Studio 2005\WebSites\EM2000Net\re sults.aspx .vb:line 766
at System.Web.UI.Control.OnLo ad(EventAr gs e)
at System.Web.UI.Control.Load Recursive( )
at System.Web.UI.Page.Process RequestMai n(Boolean includeStagesBeforeAsyncPo int, Boolean includeStagesAfterAsyncPoi nt)
Message="Specified argument was out of the range of valid values.
Parameter name: index"
ParamName="index"
Source="System.Web"
StackTrace:
at System.Web.UI.ControlColle
at ResultsMain.gvDownloadsTop
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.DataSourceVi
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at System.Web.UI.WebControls.
at ResultsMain.Page_Load(Obje
at System.Web.UI.Control.OnLo
at System.Web.UI.Control.Load
at System.Web.UI.Page.Process
i = the number of cell
j = the number of control in cell
CType(e.Row.Cells(i).Contr ols(j), Image).ImageURL = "available.gif"
also you can use
CType(e.Row.Cells(0).FindC ontrol("Im ageControl Name"), Image).ImageURL = "available.gif"
j = the number of control in cell
CType(e.Row.Cells(i).Contr
also you can use
CType(e.Row.Cells(0).FindC
ASKER
Still not finding it. I think I have to work with theTempletfield somehow.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Imports System.IO
Then, you can use the shared Exists() method to look for a specific file. With
the File class, you pass in the path as a string, like so:
If File.Exists("c:\myfile.txt
'do something
Else
'do something
End If