I have a datagrid with an edit column and a footer with an add 
hyperlink(hyperLinkAddContactSearch) in the edit column. The add 
link displays a div that has a button(buttonContactNotFound) in it 
that upon clicking should hide the footer link
(hyperLinkAddContactSearch) in the edit column and make visible a 
different link button(linkButtonContactAddNew) in the same cell in 
the footer. I have not been successful at referencing either of the 
links in the footer edit column. I 
get "System.NullReferenceException: Object reference not set to an 
instance of an object." error message when trying to access the 
visible properties of the links in the datagrid. I have tried a 
couple of datagrid.findcontrol methods and I couldn;t get that to 
work either. Maybe I am missing the event that is getting fired when 
the (buttonContactNotFound) button is getting clicked.

Any thoughts or tips or work arounds??

Here's my partial datagrid showing the edit column.

<asp:datagrid id="dataGridContacts" runat="server" Width="700px" 
AutoGenerateColumns="False" ShowFooter="True">
                <Columns>
                  <asp:TemplateColumn Visible="False" 
HeaderText="ContactID">
                    <ItemTemplate>
                      <asp:Label runat="server" ID="labelContactID" 
Text='<%# DataBinder.Eval(Container, "DataItem.ContactID") %>'>
                      </asp:Label>
                    </ItemTemplate>
                  </asp:TemplateColumn>
                  <asp:TemplateColumn HeaderText="Edit">
                    <ItemTemplate>
                      <asp:LinkButton runat="server" Text="Edit" 
CausesValidation="false" ID="linkButtonContactEdit" 
CommandName="Edit"
                        CommandArgument="{0}" 
OnCommand="linkButtonContactEdit_Click"></asp:LinkButton>
                    </ItemTemplate>
                    <FooterTemplate>
                      <a href="#" ID="hyperLinkAddContactSearch" 
onclick="hyperLinkAddContactSearch_Click();">
                        Add</a>
                      <asp:LinkButton Visible="False" runat="server" 
Text="Insert" CausesValidation="false" ID="linkButtonContactAddNew"
                        CommandName="AddNew" 
OnCommand="linkButtonContactAddNew_Click"></asp:LinkButton>
                    </FooterTemplate>
                    <EditItemTemplate>
                      <asp:LinkButton runat="server" Text="Update" 
CausesValidation="false" ID="linkButtonContactUpdate" 
CommandName="Update" CommandArgument='<%# DataBinder.Eval
(Container, "DataItem.ContactID") %>' 
OnCommand="linkButtonContactUpdate_Click">
                      </asp:LinkButton>
                      <asp:LinkButton runat="server" Text="Delete" 
CausesValidation="false" ID="linkButtonContactDelete" 
CommandName="Delete" CommandArgument='<%# DataBinder.Eval
(Container, "DataItem.ContactID") %>' 
OnCommand="linkButtonContactDelete_Click">
                      </asp:LinkButton>
                      <asp:LinkButton runat="server" Text="Cancel" 
CausesValidation="false" ID="linkButtonContactCancel"
                        CommandName="Cancel" 
OnCommand="linkButtonContactCancel_Click"></asp:LinkButton>
                    </EditItemTemplate>
                  </asp:TemplateColumn>

Here's the div with the button.

      <div id="divContactSearch" style="DISPLAY: none;POSITION: 
absolute" runat="server">
        <TABLE id="tableContactSearch" height="100" cellSpacing="0" 
cellPadding="3" width="300">
          <TR id="tableRowContactSearchHeader">
            <TD><asp:label id="labelContactSearch" 
runat="server">Contact Search</asp:label></TD>
            <TD></TD>
          </TR>
          <TR id="tableRowContactSearchItem">
            <TD><asp:dropdownlist id="dropDownListSearchContacts" 
runat="server"></asp:dropdownlist></TD>
            <TD><asp:button id="buttonContactAddExisting" 
runat="server" Text="Add"></asp:button></TD>
          </TR>
          <TR id="tableRowContactSearchItem2">
            <TD>
            <TD><asp:button id="buttonContactNotFound" 
runat="server" Text="Not Found"></asp:button></TD>
          </TR>
          <TR id="tableRowContactSearchFooter">
            <TD></TD>
            <TD><A onclick="divHide('divContactSearch')" 
href="#">Cancel</A></TD>
          </TR>
        </TABLE>
      </div>

Here's my event handler for the button to try and hide and show the 
links.

    private void buttonContactNotFound_Click(object sender, 
System.EventArgs e)
    {
      hyperLinkAddContactSearch.Visible = false;
      linkButtonContactAddNew.Visible = true;
    }

Thanks,
Jim





------------------------ Yahoo! Groups Sponsor --------------------~--> 
1.2 million kids a year are victims of human trafficking. Stop slavery.
http://us.click.yahoo.com/WpTY2A/izNLAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

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

<*> 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