Using RequiredFieldValidator in FooterTemplate

Discussion in 'ASP .Net Datagrid Control' started by Danno, Sep 10, 2003.

  1. Danno

    Danno Guest

    Hi,

    I'm having pasted below when trying to use a RequiredFieldValidtator(RFV) in
    the Footer Template.

    Here is a snipet of the code. Note that the code works without the
    inclusion of the RFV into the FooterTemplate. The RFV in the EditTemplate
    does work.

    Thanks for any help you can provide,
    Dan

    Code:

    <asp:TemplateColumn HeaderText="First Name" SortExpression="FName
    ASC">
    <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem, "FName")%>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox id="FName" text='<%#
    DataBinder.Eval(Container.DataItem, "FName") %>'
    runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator id="Requiredfieldvalidator2"
    ControlToValidate="FName" Display="Dynamic"
    runat=server>&nbsp;*</asp:RequiredFieldValidator>
    </EditItemTemplate>
    <FooterTemplate>
    <asp:TextBox id="newFName" size="10" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator id="Requiredfieldvalidator1"
    ControlToValidate="newFName" Display="Dynamic"
    runat=server>&nbsp;*</asp:RequiredFieldValidator>
    </FooterTemplate>
    </asp:TemplateColumn>

    Error:
    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set
    to an instance of an object.

    Source Error:

    Line 285: {
    Line 286: MyDataGrid.CurrentPageIndex = 0;
    Line 287: MyDataGrid.DataBind();
    Line 288: }
    Line 289: ShowStats();

    Source File: c:\dev\src\asp\coreengine\datagridtest.aspx.cs Line: 287

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an
    object.]
    System.Web.UI.WebControls.BaseValidator.OnInit(EventArgs e) +22
    System.Web.UI.Control.InitRecursive(Control namingContainer) +235
    System.Web.UI.Control.InitRecursive(Control namingContainer) +179
    System.Web.UI.Control.InitRecursive(Control namingContainer) +179
    System.Web.UI.Control.AddedControl(Control control, Int32 index) +185
    System.Web.UI.ControlCollection.Add(Control child) +153
    System.Web.UI.WebControls.RowControlCollection.Add(Control child) +33
    System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) +26
    System.Web.UI.WebControls.RowControlCollection.AddAt(Int32 index, Control
    child) +37
    System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex, Int32
    dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,
    DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
    pagedDataSource) +138
    System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
    useDataSource) +1485
    System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +49
    System.Web.UI.WebControls.BaseDataList.DataBind() +23
    ClickTactics.Web.CoreEngine.DataGridTest.DataBindGrid() in
    c:\dev\src\asp\coreengine\datagridtest.aspx.cs:287
    ClickTactics.Web.CoreEngine.DataGridTest.BindGrid() in
    c:\dev\src\asp\coreengine\datagridtest.aspx.cs:276
    ClickTactics.Web.CoreEngine.DataGridTest.MYPage_Load(Object sender,
    EventArgs e) in c:\dev\src\asp\coreengine\datagridtest.aspx.cs:63
    ClickTactics.Web.CoreEngine.DataGridTest.Page_Load(Object sender,
    EventArgs e) in c:\dev\src\asp\coreengine\datagridtest.aspx.cs:50
    System.Web.UI.Control.OnLoad(EventArgs e) +67
    System.Web.UI.Control.LoadRecursive() +29
    System.Web.UI.Page.ProcessRequestMain() +724
    Danno, Sep 10, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jorge Loaiza Arango

    Access to controls in <FooterTemplate>

    Jorge Loaiza Arango, Dec 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    603
    Jose Suero
    Dec 21, 2003
  2. =?Utf-8?B?bWFoc2E=?=

    how can I access to controls in footertemplate

    =?Utf-8?B?bWFoc2E=?=, Jul 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    319
    =?Utf-8?B?bWFoc2E=?=
    Jul 9, 2004
  3. Vishal

    Footertemplate is called twice?

    Vishal, Jan 12, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    325
    Scott Allen
    Jan 12, 2005
  4. Arthur Dent

    Repeater footertemplate shows on TOP

    Arthur Dent, Sep 28, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    718
    Eliyahu Goldin
    Sep 28, 2005
  5. Will Chamberlain

    Can't Populate FooterTemplate Label

    Will Chamberlain, Sep 28, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    498
    Will Chamberlain
    Sep 29, 2005
Loading...

Share This Page