Chaps..
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:
Code:
<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" ect ect>
<asp:TemplateFieldHeaderText="Sub Groups">
<ItemTemplate>
<asp:ImageButtonID="ImgButGridGroup"runat="server"CausesValidation="false"CommandName="showSubGroups"ImageUrl="~/images/icons/gridgroups.jpg"Text="Button"/>
</ItemTemplate>
</asp:TemplateField>
My
VB Code is
Code:
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"
Else
ImgButGridGroup.ImageUrl = "~/images/background/1pxWhiteSpace.jpg"
EndIf
NextEndSub
As far as i can tell from the debug watch the datasource value is comming through fine..
The error i am getting is
Code:
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!!
Cheers
Aspless