listview and datalist not updating,inserting
<p>Data entered in textboxes is not getting updated in database. In debug mode I see that text1 and text2 in ItemUpdating event contain the same values as they had before calling ItemUpdating.</p>

<p>Here's my listview control:</p>

<pre><code>&lt;asp:ListView ID="ListView1" runat="server"
onitemediting="ListView1_ItemEditing"
onitemupdating="ListView1_ItemUpdating"
oniteminserting="ListView1_ItemInserting"&gt;

//LayoutTemplate removed

&lt;ItemTemplate&gt;
      &lt;asp:Label ID="Label2" runat="server" Text='&lt;%#Eval("id")%&gt;'&gt;&lt;/asp:Label&gt;
      &lt;asp:Label ID="Label3" runat="server" Text='&lt;%#Eval("text1")%&gt;'&gt;&lt;/asp:Label&gt;

      &lt;asp:LinkButton ID="LinkButton2" CommandName="Edit" runat="server"&gt;Edit&lt;/asp:LinkButton&gt;
      &lt;asp:LinkButton ID="LinkButton4" CommandName="Delete" runat="server"&gt;Delete&lt;/asp:LinkButton&gt;
&lt;/ItemTemplate&gt;
&lt;EditItemTemplate&gt;
    &lt;asp:Label ID="Label1" runat="server" Text='&lt;%#Eval("id")%&gt;'&gt;&lt;/asp:Label&gt;
    &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%#Eval("text1")%&gt;' TextMode="MultiLine" /&gt;
    &lt;asp:TextBox ID="TextBox2" runat="server" Text='&lt;%#Eval("text2")%&gt;' Height="100" TextMode="MultiLine" /&gt;

    &lt;asp:LinkButton ID="LinkButton1" CommandName="Update" CommandArgument='&lt;%# Eval("id")%&gt;' runat="server"&gt;Update&lt;/asp:LinkButton&gt;
    &lt;asp:LinkButton ID="LinkButton5" CommandName="Cancel" runat="server"&gt;Cancel&lt;/asp:LinkButton&gt;
&lt;/EditItemTemplate&gt;
&lt;InsertItemTemplate&gt;
    &lt;asp:TextBox ID="TextBox3" runat="server" TextMode="MultiLine" Height="100"&gt;&lt;/asp:TextBox&gt;
    &lt;asp:TextBox ID="TextBox4" runat="server" Height="100" TextMode="MultiLine"&gt;&lt;/asp:TextBox&gt;

    &lt;asp:LinkButton ID="LinkButton3" runat="server"&gt;Insert&lt;/asp:LinkButton&gt;
&lt;/InsertItemTemplate&gt;
&lt;/asp:ListView&gt;
</code></pre>

<p>Codebehind file:</p>

<pre><code>protected void ListView1_ItemEditing(object sender, ListViewEditEventArgs e)
{
    ListView1.EditIndex = e.NewEditIndex;
    BindList();
}
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
    ListViewItem myItem = ListView1.Items[ListView1.EditIndex];

    Label id = (Label)myItem.FindControl("Label1");
    int dbid = int.Parse(id.Text);

    TextBox text1 = (TextBox)myItem.FindControl("Textbox1");
    TextBox text2 = (TextBox)myItem.FindControl("Textbox2");

    //tried to work withNewValues below, but they don't work, "null reference" error is being thrown
    //text1.Text = e.NewValues["text1"].ToString();
    //text2.Text = e.NewValues["text2"].ToString();

    //odbc connection routine removed.
    //i know that there should be odbc parameteres:
    comm = new OdbcCommand("UPDATE table SET text1 = '" + text1.Text + "', text2 = '" + text2.Text + "' WHERE id = '" + dbid + "'", connection);

    comm.ExecuteNonQuery();
    conn.Close();

    ListView1.EditIndex = -1;
    //here I databind ListView1
}
</code></pre>

<p>What's wrong with updating of text1.Text, text2.Text in ItemUpdating event? Should I use e.NewValues property? If so, how to use it?</p>

<p>Thanks in advance for any help.</p>
