У меня есть ListView внутри FormView, который по какой-то странной причине не запускает ни ItemInsert, ни ItemCommand.Я заполняю ListView с общим списком.Я связываю список с ListView на OnPreRenderComplete.
<asp:ListView runat="server" ID="lvReferences" DataKeyNames="idReference" OnItemInserting="ContractReferences_Inserting" OnItemDeleting="ContractReferences_Deleting" InsertItemPosition="LastItem" OnItemCommand="ContractReferences_Command" OnItemCreated="ContractReferences_ItemDataBound">
<LayoutTemplate>
<ul>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<li class="obsItem">
<a href="#"><asp:TextBox ID="valRef" runat="server" Width="5px" Enabled="false" Text='<%#Bind("idProcessRecordRef") %>' /></a>
<asp:TextBox id="txtRef" runat="server" Text='<%#Bind("description") %>' />
<asp:ImageButton ID="btDelete" runat="server" CommandName="Delete" ImageUrl="~/_layouts/web.commons/Images/eliminar.png" />
</li>
</ItemTemplate>
<InsertItemTemplate>
<li class="obsItem">
<a href="#"><asp:TextBox ID="valRef" runat="server" Width="5px" Enabled="false" /></a>
<asp:TextBox id="txtRef" runat="server" />
<asp:ImageButton ID="btDetail" CausesValidation="false" OnClientClick="javascript:openPopup();return false;" runat="server" ImageUrl="~/_layouts/web.commons/Images/novo.png" />
<asp:ImageButton ID="btSaveDs" runat="server" CommmandName="Insert" CausesValidation="false" ImageUrl="~/_layouts/web.commons/Images/gravarObs.png" />
</li>
</InsertItemTemplate>
</asp:ListView>
Мой метод ItemDataBound:
protected void ContractReferences_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (!IsPostBack)
{
TextBox valRef = e.Item.FindControl("valRef") as TextBox;
TextBox txtRef = e.Item.FindControl("txtRef") as TextBox;
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "function openPopup(){ window.open('ContractPicker.aspx?c1=" + valRef.ClientID + "&c2=" + txtRef.ClientID + "');}", true);
}
}
Итак, в основном, в InsertItemTemplate я помещаю кнопку, которая открывает LOV изаполняет мои поля valRef и txtRef.Я должен был поставить «return false», чтобы родительская страница не отправляла (и я думаю, что проблема здесь ...).Затем, когда я щелкаю в ImageButton с CommandName = "Insert", вместо запуска события ItemCommand, он снова вводится в обработчик ItemDataBound.
Итак, есть идеи?
Спасибо!