score:0

hope that will serve someone, somewhere.

here is my code to get that to work:

1) i have a listview wich hold a user control when editing. this user cotnrol has itself a listview inside

<asp:listview runat=server id=c_lv_myobjects datakeynames="id" 
    onitemdatabound=databoundmyobjects onitemediting=itemediting
     >
<layouttemplate>
            <table runat=server id="itemplaceholdercontainer">
                <tr>
                    <th>
                        description
                    </th>
                </tr>
                <tr runat="server" id="itemplaceholder">
                </tr>
            </table>
        </layouttemplate>
        <itemtemplate>
            <tr>
                <td>
                    text...
                </td>
                <td>
                    <asp:linkbutton runat="server" commandname="edit" text="edit"></asp:linkbutton>
                </td>
                <td>
                    <asp:linkbutton runat="server" commandname="delete" text="delete"></asp:linkbutton>
                </td>
         </itemtemplate>
         <edititemtemplate>
            <tr>
                <td colspan=3>
                   <mytag:myuc id=c_uc_myusercontrol runat=server 
                                onediting=myobjectediting
                                 />
                </td>
            </tr>
        </edititemtemplate>
        <emptydatatemplate>
            no results found!
        </emptydatatemplate>
    </asp:listview>

the code c# for this listview is as follows :

public int editindexcomposition;

protected void itemediting(object sender, listviewediteventargs e)
        {
            c_lv_myobjects.editindex = e.neweditindex;
            c_lv_myobjects.databind();
        }

        protected void myobjectediting(object sender, eventargs e)
        {
            listviewediteventargs myevent = (listviewediteventargs)e;
            if (myevent != null)
                editindexcomposition= myevent.neweditindex;

            c_lv_myobjects.databind();

        }

        protected void databoundmyobjects(object sender, listviewitemeventargs e)
        {
            myuc uc = (myuc)e.item.findcontrol("c_uc_myusercontrol");

            if (uc!=null)
            {
                uc.editindex = editindexcomposition;
                listviewdataitem dataitem = (listviewdataitem)e.item;
                myobject obj= (myobject)dataitem.dataitem;
                uc.datasource=myservice.getdatasource(obj.id);
                uc.databind();

            }
        }

and the code of my usercontrol is as follows :

<asp:placeholder runat="server" id="c_ph_objcomposition">
    <asp:listview runat="server" id="c_lv_appaltatorecomposizione" datasource="<% # datasource %>"
        datakeynames="id" onitemediting="itemediting">

           etc...

 <itemtemplate>
            <tr>
                <td>
                    <asp:linkbutton runat="server" commandname="edit" text="edit"></asp:linkbutton>
                </td>
            </tr>
        </itemtemplate>
        <edititemtemplate>
            <tr>
                <td>
                    edit mode
                </td>
             </tr>
        </edititemtemplate>
    </asp:listview>
</asp:placeholder>

with the following code c# :

public int editindex 
        {
            get {return c_lv_objcomposition.editindex;}
            set { c_lv_objcomposition.editindex=value;}
        }

public event eventhandler editing;

 protected void itemediting(object sender, listviewediteventargs e)
        {
            c_lv_objcomposition.editindex = e.neweditindex;

            if (editing != null)
                editing(this, e);

        }

when clicking on the edit button of the innerlistview, we store the index that was clicked and we trigger a function in the first container user control. this function is going to store in a global value the index cliked and triggers a databind of the outter list. doing so we get the onitemdatabound, that will recreate our usercontrol with the proper values, we can then before the databinding of the usercontrol assign the index of the editing row.

that's all if you have any questions , please feel free to answer..

ciao!

score:2

this is an interesting problem. almost certainly a databinding issue. in order to enter edit mode you must do two things:

1) set the editindex
2) call databind()

in the case of nested repeaters though... when does render get called? i suspect you will have to call databind() on the parent in order to render everything correctly. that being the case you may have to then set the editindex again, since you are rebinding the parent.

edit: ok... i just tried this with a nested gridview and i did not have to databind() the parent to get the sub grid to enter edit mode. now i have to downvote my own answer. :|


Related Query

More Query from same tag