troubleshooting Question

ASP.NET Find control in footer row

Avatar of doramail05
doramail05Flag for Malaysia asked on
ASP.NETMicrosoft SQL Server 2008
4 Comments1 Solution1369 ViewsLast Modified:
having txtGotoPage in the footer row in the gridview, with 3 methods to findcontrol, but didnt work well,

<PagerTemplate>
       <asp:ImageButton ID="ImgFirst" runat="server"
            ImageUrl="~/images/i_first_e.gif" CommandArgument="First" />
        <asp:ImageButton ID="ImgPrev" runat="server"
            ImageUrl="~/images/i_previous_e.gif" CommandArgument="Prev" />
 <asp:Label ID="lblPageNum"
            runat="server"></asp:Label>
       
        of <asp:Label ID="lblPageCount"
            runat="server"></asp:Label>
 
<asp:ImageButton ID="ImgNext" runat="server"
            ImageUrl="~/images/i_next_e.gif" CommandArgument="Next" />
        <asp:ImageButton ID="ImgLast" runat="server"
            ImageUrl="~/images/i_last_e.gif" CommandArgument="Last" />

            <asp:TextBox ID="txtGotoPage" runat="server" Width="30" />
            <asp:Button ID="btnGoTo" runat="server" Text="Goto" OnClick="btnGoTo_Click" />

       </PagerTemplate>

1)

      string strGotoPage = ((TextBox)GV_Data.FooterRow.FindControl("txtGotoPage")).Text.ToString();

            if (strGotoPage != String.Empty)
            {
                GetData(ViewState["SortBy"].ToString(), lbl_SortOrder.Text, ViewState["ColName"].ToString(), ViewState["ColVal"].ToString(), int.Parse(strGotoPage));
            }

2)
            TextBox t1 = (TextBox)GV_Data.FooterRow.FindControl("txtGotoPage");

            if (t1.Text != String.Empty)
            {
                GetData(ViewState["SortBy"].ToString(), lbl_SortOrder.Text, ViewState["ColName"].ToString(), ViewState["ColVal"].ToString(), int.Parse(t1.Text.ToString()));
            }

 3)

           foreach (DataControlFieldCell gvFooterCells in GV_Data.FooterRow.Cells)
            {
                TextBox _txtGoto = (TextBox)gvFooterCells.FindControl("txtGotoPage");

                if (_txtGoto.Text != "")
                {
                    GetData(ViewState["SortBy"].ToString(), lbl_SortOrder.Text, ViewState["ColName"].ToString(), ViewState["ColVal"].ToString(), int.Parse(_txtGoto.Text.ToString()));
                }

            }
ASKER CERTIFIED SOLUTION
doramail05

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros