Why in the world would you bind the GridView twice, once in the
Page_Init and then in the Page_Load ?!

If you could post a short but complete sample for us to try out (the
one above obviously won't work for us), we could test it out.

On Sep 29, 10:11 pm, Barun <[email protected]> wrote:
> I am having problem in maintaining state of gridview when performing
> search. My Code goes like this:
>
> protected void Page_Init(object sender, EventArgs e)
>     {
>         if (!IsPostBack)
>         {
>             GridView1.DataSource = DataSource;
>             GridView1.DataBind();
>         }
>     }
> protected void Page_Load(object sender, EventArgs e)
>     {
>             string  strSql = "Select * from EMPLOYEE"            ;
>             strSql = strSql + "Where " + " E_NAME = TEST"; // depends
> on search criteria. For now i have simple SQL statement
>
>             DataTable dt =DataSource.GetData();
>             DataRow[] dr = dt.Select(strSql);
>             GridView1.DataSource = dr;
>             GridView1.DataBind();}
>
> protected void GridView1_SelectedIndexChanging(object sender,
> GridViewSelectEventArgs e)
>     {
>         usercontrol.BuildEmployeRecord(userID, Info);
>     }
>
> Each row in gridview have toggle button to expand and collapse, when
> clicked, it will call user control to display information related with
> that particular record.
> The problem is when i click any linkbutton inside user control it will
> collapse the row without performing any task it is supposed to do.
> I guess the problem is in GridView. When no search is performed
> everything works fine. Only when search is performed I am getting this
> problem. When Search is performed it re binds the gridview and view
> state iformation is changed. Since view state information is changed
> the user control won't be able to get same information for any action
> to perform.
>
> I'd really appreciate if you can provide me with suitable example to
> solve this problem or any glimpse on how to maintain view state even
> after gridview is rebind.
> Thank you.

Reply via email to