I think the reason why I am getting this error sporadically is because I 
have a parent GridView and the child formView on the same page. One 
has to select a record in the GridView, then the FormView is displayed. 
When a user first arrive at this page, the FormView is not drawn yet. 

How can I get it to display the child formView along w/ the GridView on 
the first load? It's either this workaround or I need to read in the 
commandName of FormView1. I can't use ' If e.commandName = "Edit"' 
in FormView1_DataBound. It doesn't like it. ;( 

Maybe I can do this?
 Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal 
e As System.EventArgs) Handles FormView1.DataBound
       If FormView1.FindControl("ddlApprovers") isObject Then 
*** not sure of the exact code. am still figuring it out ****
           'fill in the dropdownlist
       end if

Please point me to the right direction. Thanks! 

'-------- error--------------------------------------------
System.NullReferenceException: Object reference not set to an 
instance of an object 
'----------------------------------------------------------- 
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AllowSorting="True"
            AutoGenerateColumns="False"  
            DataKeyNames="TaskID" DataSourceID="SqlDataSource1"
            CellPadding="4"
            Font-Names="Arial" Font-Size="8pt" ForeColor="#333333">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" 
ForeColor="White" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" 
ButtonType="Button" />
                <asp:BoundField DataField="TaskID" HeaderText="TaskID" 
InsertVisible="False" ReadOnly="True"
                    SortExpression="TaskID" />
.......................................
<asp:FormView ID="FormView1" runat="server" 
DataKeyNames="TaskID" DataSourceID="SqlDataSource2" 
DefaultMode="Edit">
            <EditItemTemplate>
.................
~Approved By:
                <asp:DropDownList ID="ddlApprovers" runat="server">
                     </asp:DropDownList>
.................
'-----------------------------------------------------

Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal 
e As System.EventArgs) Handles FormView1.DataBound 

Dim aDDL As DropDownList = FormView1.FindControl("ddlApprovers") 
aDDL.Items.Insert(0, "testing") 
aDDL.Items.Insert(0, "testing2") 
aDDL.DataBind() 

End Sub

--- In [email protected], "Dean Fiala" <[EMAIL PROTECTED]> wrote:
>
> Post your code.
> 
> On 4/3/06, orangefluffybun <[EMAIL PROTECTED]> wrote:
> > I am using code to bind a ddl in the edit mode of my child formView.
> > It's giving me an "Object reference not set to an instance of an
> > object" error because it can not find the ddl. Where am I suppose to
> > bind this ddl? Please please help........
> >
> > Thank you!
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> --
> Dean Fiala
> Very Practical Software, Inc
> Now with Blogging...
> http://www.vpsw.com/blogbaby
>








 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNet2/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to