views:

786

answers:

1

All,

My problem is that my gridview header that contains textboxes etc. that users can type into is somehow losing the content of those textboxes when the user forces a postback - but only if I have a user control in the header. This is using .NET 2.0.

I've created a basic gridview that binds to a generic list datasource. I've added a simple user control (wrap a text box) into the header and I update the text of this this during the RowCreated event (my actual code is not that simple, this is just a test).

In the RowCreated event I can reference my user control fine and the normal textboxes retain values (regardless of whether the gridview as Viewstate on or off NB: I rebind each time if viewstate is off). However, the moment I access the usercontrol properties the normal textboxes lose any content and are redisplayed as empty.

I am totally stumped. This must be a bug, but I can't find it anywhere.

Example code:

    protected void grdList_RowCreated(object sender, GridViewRowEventArgs e)
    {
        switch (e.Row.RowType)
        {
            case DataControlRowType.Header:
                TextBoxWrapper tbw = (TextBoxWrapper)e.Row.FindControl("utxWrapper");
                TextBox txn = (TextBox)e.Row.FindControl("txtClientId");
                txn.Text = tbw.ClientId;

                break;
        }
    }

Remove the "txn.Text = tbw.ClientId;" and the code is fine. NB: tbw is not null, i.e. it does contain a reference.

Grid definition:

<asp:GridView ID="grdList" runat="server" DataKeyNames="Id" AutoGenerateColumns="false" OnRowCreated="grdList_RowCreated" OnRowCommand="grdList_RowCommand" ShowFooter="true" EnableViewState="false">

A: 

Having the same issue, I believe this is a MS bug, they don't persist these items. And why should they want to.

asdf