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. :|
Source: stackoverflow.com
Related Query
- How to Edit data in nested Listview
- How does linq actually execute the code to retrieve data from the data source?
- How to fill data in nested Lists based on Ids in C#?
- How can i copy data table records of different field name based on mapping list evaluating condition on source data table?
- C# LINQ How to get a data source from a db?
- how to combine two data source into one?
- How to swap the data source associated with a Linq query?
- How to Query Icollections of Entity Framework Code First Data
- How do I return single data from primary table and multiple entries in second table nested after join
- How can this Data Access Code Lose Data?
- ASP.Net LINQ data source error is ListView
- How do you LINQ data into ObservableCollection with nested ObservableCollection?
- How to get data from a ListView in Dictionary format in C# winforms
- How to insert multiple rows of data from listview to linq to sql VB.Net
- How to design nested query for fetching data from tables of MS SQL using Entity Framework?
- how to select data by linq in many-to-many relationship in First code Entity framework 5
- how to handle source data changes in LINQ?
- How to display data from XML file to ListView using LINQ to XML?
- How to link data from nested relational tables in a C# query
- How to reinsert data from one table onto itself using LINQ in code migration?
- C# LINQ or for loop How to get a data source from a db?
- How to add elements for particular data object in nested loop in c#?
- How to efficiently edit data in a database?
- How to optimize code that changes a value deeply nested in an object graph
- C# : How to add data data from a ListView control to a Dictionary
- How do I edit this LINQ query for nested classes using Entity Framework
- How to read data from a nested select query linq
- c# Linq or code to extract groups from a single list of source data
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- How to get the nested child data in SQL Server
More Query from same tag
- Multiplying Issue
- Why does C# not allow anonymous cast to objects?
- Linq left joining 3 tables
- using linq to select last written file
- Using LINQ how to transform a List of Lists using elements index
- Lambda expression to return a string from a 2D string array based on a test string
- Grouping a list of list using linq
- Linq: Select from 2 datatable where column id from first table = column id from second table
- Compare 2 lists and reduce quantities of resulting list
- LINQ WHERE clause equivalent in javascript
- Check if string already exist in Table
- Should we always use .Find() rather than .FirstOrDefault() when we have the primary key in Entity Framework Core?
- What's your favorite LINQ to Objects operator which is not built-in?
- I have a LINQ statement that is partially query and partially method. How can I do this using one or the other?
- MongoDB Array Query
- How to get an specific node in xml with namespaces?
- Unexpected result with Where()
- dbmetal visual metal error:"magma string must not be empty"
- How to leverage dynamic programming inside of a Linq Where clause?
- Understanding overloads of GroupBy in Linq
- Selecting the first item from a query eficiently
- When I delete an item from the database and updatethe datagrid, I still see this object
- Cannot convert type bool to int
- Create a LINQ query comparing arrays
- Conditional AND to include in WHERE condition using stored procedure
- Complex LINQ query in a workflow
- Convert an integer range to a list of strings using LINQ
- Join multiple list on property in parallel
- Get Parent and then Child objects conditionally
- Remove an Item from C# Enum List