Dec 01, 2011, 6:34 PM
[CLOSED] Ext.NET equivalent of this sample
I have a pattern that I find myself doing a great deal when using plain ASP.NET (see the sample below). I haven't been able to come up with the equivalent "thing" in ext.net yet. So far, I've been able to work around this using other techniques, until now.
Is there a way that I can do something similar with Ext.NET? The biggest problem I've found is that I need the items to be able to contain plain HTML. In my specific case, it's just a big paragraph of text.
Ultimately what I need is a vertical list of chunks of text that come from my database. I need to be able to edit, delete and add them.
Is there a way that I can do something similar with Ext.NET? The biggest problem I've found is that I need the items to be able to contain plain HTML. In my specific case, it's just a big paragraph of text.
Ultimately what I need is a vertical list of chunks of text that come from my database. I need to be able to edit, delete and add them.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
DataBind()
End If
End Sub
Public Overrides Sub DataBind()
Dim data As New List(Of Object)
For i = 0 To 5
data.Add(New With {.ID = i, .Text = "Item " & i})
Next
ItemList.DataSource = data
ItemList.DataBind()
End Sub
Protected Sub ItemList_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewUpdateEventArgs) Handles ItemList.ItemUpdating
Dim item = ItemList.Items(ItemList.EditIndex)
'update data item
ItemList.EditIndex = -1
DataBind()
End Sub
Protected Sub ItemList_ItemEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewEditEventArgs) Handles ItemList.ItemEditing
ItemList.EditIndex = e.NewEditIndex
DataBind()
End Sub
Protected Sub ItemList_ItemCanceling(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCancelEventArgs) Handles ItemList.ItemCanceling
ItemList.EditIndex = -1
DataBind()
End Sub
Protected Sub ItemList_ItemDeleting(ByVal sender As Object, ByVal e As ListViewDeleteEventArgs) Handles ItemList.ItemDeleting
Dim item As ListViewDataItem = ItemList.Items(e.ItemIndex)
Dim id = ItemList.DataKeys(item.DataItemIndex).Values("ID")
'delete data item
DataBind()
End Sub
Protected Sub ItemList_ItemInserting(ByVal sender As Object, ByVal e As ListViewInsertEventArgs) Handles ItemList.ItemInserting
'insert data item
DataBind()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListView ID="ItemList" runat="server" DataKeyNames="ID" InsertItemPosition="FirstItem">
<LayoutTemplate>
<table>
<asp:PlaceHolder ID="ItemPlaceHolder" runat="server" />
</table>
</LayoutTemplate>
<InsertItemTemplate>
<tr>
<td>
<asp:TextBox ID="Text" runat="server" TextMode="MultiLine" />
<asp:Button ID="AddButton" runat="server" Text="Add" />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="Text" runat="server" Text='<%# Bind("Text") %>' />
<asp:Button ID="EditButton" runat="server" Text="Edit" CommandName="edit" CommandArgument='<%# Bind("ID") %>' />
<asp:Button ID="DeleteButton" runat="server" Text="Delete" CommandName="delete" CommandArgument='<%# Bind("ID") %>' />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr>
<td>
<asp:TextBox ID="Text" runat="server" TextMode="MultiLine" />
<asp:Button ID="SaveButton" runat="server" Text="Save" CommandName="update" CommandArgument='<%# Bind("ID") %>' />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" CommandName="cancel" CausesValidation="false" />
</td>
</tr>
</EditItemTemplate>
</asp:ListView>
</div>
</form>
</body>
</html>
Last edited by Daniil; Dec 12, 2011 at 3:04 PM.
Reason: [CLOSED]