View Single Post
  #1 (permalink)  
Old August 26th, 2011, 06:54 PM
aspless aspless is offline
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default Set ImageButton.ImageUrl


I am hoping i'm not to far off on this one..

I am reading a value from a datasource and based on a simple bit value wish to alter the ImageButton.ImageUrl associated with a gridview.

The Gridview Variables are:

<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" ect ect>
<asp:TemplateFieldHeaderText="Sub Groups">
My VB Code is

ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Load
Dim dvSql AsDataView = DirectCast(SqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView)
ForEach drvSql AsDataRowViewIn dvSql
Dim SubGrpImgVal AsInteger = drvSql("subgroupimg").ToString
Dim ImgButGridGroup AsImageButton = CType(GridView1.FindControl("ImgButGridGroup"), ImageButton)
If SubGrpImgVal = 1 Then
ImgButGridGroup.ImageUrl = "~/images/icons/gridmembers.jpg"
ImgButGridGroup.ImageUrl = "~/images/background/1pxWhiteSpace.jpg"
As far as i can tell from the debug watch the datasource value is comming through fine..

The error i am getting is
Object reference not set to an instance of an object
Which indicates that there is a mismatch but can't see what part of the ImageButton reference is not working.

Still very much getting to grips with VB..

Any assist would be appreciated!!


Reply With Quote