accessing control in EmptyDataTemplate

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    #1

    accessing control in EmptyDataTemplate

    hi

    asp.net 2.0

    I have a GridView here with some controls in it's EmptyDataTempla te. I'm
    wondering how I can get access to those controls. I've tryed using
    FindControl, but that doesn't work because EmptyDataTempla te doesn't have
    that method

    <EmptyDataTempl ate>
    <asp:TextBox ID="txtCode" runat="server"> </asp:TextBox>
    <asp:TextBox ID="txtDesc" runat="server"> </asp:TextBox>
    <asp:LinkButt on ID="lbEmpty" OnClick="lbEmpt y_Click" runat="server"> Legg
    til</asp:LinkButton>
    </EmptyDataTempla te>

    (BTW, it is in the lbEmpty_Click method I'm trying to access the txtCode and
    txtDesc textboxes. it's here the problem occur)

    Any suggestions?


  • bruce barker

    #2
    Re: accessing control in EmptyDataTempla te

    try:


    void lbEmpty_Click(O bject sender, EventArgs e)
    {
    var parent = ((Control) sender).Parent;
    var txtCode = parent.FindCont rol("txtCode") as TextBox;
    var txtDesc = parent.FindCont rol("txtDesc") as TextBox;
    }


    -- bruce (sqlwork.com)

    Jeff wrote:
    hi
    >
    asp.net 2.0
    >
    I have a GridView here with some controls in it's EmptyDataTempla te. I'm
    wondering how I can get access to those controls. I've tryed using
    FindControl, but that doesn't work because EmptyDataTempla te doesn't have
    that method
    >
    <EmptyDataTempl ate>
    <asp:TextBox ID="txtCode" runat="server"> </asp:TextBox>
    <asp:TextBox ID="txtDesc" runat="server"> </asp:TextBox>
    <asp:LinkButt on ID="lbEmpty" OnClick="lbEmpt y_Click" runat="server"> Legg
    til</asp:LinkButton>
    </EmptyDataTempla te>
    >
    (BTW, it is in the lbEmpty_Click method I'm trying to access the txtCode and
    txtDesc textboxes. it's here the problem occur)
    >
    Any suggestions?
    >
    >

    Comment

    Working...