mayank jain

mayank jain

  • NA
  • 7
  • 0

error : panel1 does not exits in correct context

Jul 21 2009 9:35 AM
plz tel me how to resolve that error

my code is
<asp:GridView ID="gridView" runat="server" Style="position: relative; left: 299px; top: 69px;" PageSize="5" OnRowCommand="gridView_OnRowCommand" AllowPaging="True" OnSelectedIndexChanged="gridView_SelectedIndexChanged1" >

<PagerTemplate>
<% if (gridView.PageIndex > 0)
{ %>
<asp:ImageButton ID="imgBtnPrevious" runat="server" Style="vertical-align: middle;" ImageUrl="pre.jpg" OnClick="click1"
CommandArgument="Prev" CommandName="Page" />

<% } %>

<%=(gridView.PageIndex * 5) + 1%> <%=(gridView.PageIndex * 5) + gridView.Rows.Count%>
<% if (gridView.PageIndex != (gridView.PageCount - 1))
{ %>



<asp:ImageButton ID="imgBtnNext" runat="server" Style="vertical-align: middle;" ImageUrl="next.jpg" OnClick="click" CommandArgument="Next" CommandName="Page" />
<% } %>

<%--<asp:ImageButton ID="imgBtnNext" runat="server"
Style="vertical-align: middle;" ImageUrl="next.jpg"
CommandArgument='<%# Eval("Next")%>' OnClick="click" CommandName="Page" />--%>
</PagerTemplate>
</asp:GridView>
</asp:Panel>
<%--<%=(gridView.PageIndex * 5) + 1%> <%=(gridView.PageIndex * 5) + gridView.Rows.Count%> --%>
<% if (gridView.PageIndex != (gridView.PageCount - 1))
{ %>



<asp:ImageButton ID="imgBtnNext" runat="server" Style="vertical-align: middle;" ImageUrl="next.jpg" OnClick="click" CommandArgument="Next" CommandName="Page" />
<% } %>

<%--<asp:ImageButton ID="imgBtnNext" runat="server"
Style="vertical-align: middle;" ImageUrl="next.jpg"
CommandArgument='<%# Eval("Next")%>' OnClick="click" CommandName="Page" />--%>
</PagerTemplate>
</asp:GridView>

and code behind is

public partial class _Default : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{


DataSet ds = new DataSet();
SqlDataAdapter adapPaging = new SqlDataAdapter("select * from customer", "Data Source=OPWFMS-7KYGZ7SB;Initial Catalog=Mayank;User ID=sa;Password=sa");
adapPaging.Fill(ds);


gridView.DataSource = ds;
gridView.DataBind();





}

public void click1(object send, ImageClickEventArgs e)
{

GridViewPageEventArgs obj = new GridViewPageEventArgs(gridView.PageIndex - 1);

gridView.PageIndex = obj.NewPageIndex;

LinkButton exmp = new LinkButton();
exmp.Text = "exmp";
Panel1.Controls.Add(exmp);

}
public void click(object send, ImageClickEventArgs e)
{

GridViewPageEventArgs obj = new GridViewPageEventArgs(gridView.PageIndex+1);

gridView.PageIndex = obj.NewPageIndex;

}


}