G
Guest
Hi all,
I've a problem in an update operation in a repeater.
This in my code:
<asp:Repeater ID="rpCosti" EnableViewState="true" runat="server"
OnItemCommand="OnUpdate">
<ItemTemplate>
<tr>
<td><asp:Label ID="lblCitta" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "City") %>' />
</td>
<td><asp:TextBox ID="txtCosto" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Price") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<ul class="bottoni_bot">
<li>
<asp:Button id="btnSalva" CommandName="update" CommandArgument='<%#
DataBinder.Eval(Container.DataItem,"City") %>' CssClass="bottoneNuovaSalva"
Text="SAVE" runat="server" />
</li>
</ul>
</FooterTemplate>
</asp:Repeater>
and in the code-behind
protected void OnUpdate(object source, RepeaterCommandEventArgs e)
{
Repeater r = (Repeater)source;
if (e.CommandName == "update")
{
string city= e.CommandArgument.ToString();
string price= ((TextBox)e.Item.FindControl("txtCosto")).Text;
}
}
but an error occurred:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object
What's wrong on this?
Thanks a lot.
I've a problem in an update operation in a repeater.
This in my code:
<asp:Repeater ID="rpCosti" EnableViewState="true" runat="server"
OnItemCommand="OnUpdate">
<ItemTemplate>
<tr>
<td><asp:Label ID="lblCitta" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "City") %>' />
</td>
<td><asp:TextBox ID="txtCosto" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Price") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<ul class="bottoni_bot">
<li>
<asp:Button id="btnSalva" CommandName="update" CommandArgument='<%#
DataBinder.Eval(Container.DataItem,"City") %>' CssClass="bottoneNuovaSalva"
Text="SAVE" runat="server" />
</li>
</ul>
</FooterTemplate>
</asp:Repeater>
and in the code-behind
protected void OnUpdate(object source, RepeaterCommandEventArgs e)
{
Repeater r = (Repeater)source;
if (e.CommandName == "update")
{
string city= e.CommandArgument.ToString();
string price= ((TextBox)e.Item.FindControl("txtCosto")).Text;
}
}
but an error occurred:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object
What's wrong on this?
Thanks a lot.