Код сетки:
<asp:GridView ID="uxItemsGV" runat="server" AllowPaging="True" CellPadding="4"
ForeColor="#333333" GridLines="None" PageSize="20"
AutoGenerateColumns="False" OnRowEditing="uxItemsGV_RowEditing"
onpageindexchanging="uxItemsGV_PageIndexChanging"
onpageindexchanged="uxItemsGV_PageIndexChanged" AutoGenerateEditButton="True"
onrowupdated="uxItemsGV_RowUpdated" onrowupdating="uxItemsGV_RowUpdating"
onrowcancelingedit="uxItemsGV_RowCancelingEdit">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="ItemID" HeaderText="Item ID" ReadOnly="true" />
<asp:BoundField DataField="ItemName" HeaderText="Title" />
<asp:BoundField DataField="QuantityOnHand" HeaderText="Quantity" />
<asp:BoundField DataField="Totalsold" HeaderText="Total Sold" />
<asp:BoundField DataField="RetailPrice" HeaderText="SR Price" />
<asp:BoundField DataField="Dateofadd" HeaderText="Added Date" ReadOnly="true" />
</Columns>
<PagerSettings Position="TopAndBottom" FirstPageText="First"
LastPageText="Last" Mode="NextPreviousFirstLast" NextPageText=">>"
PreviousPageText="<<" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
Код позади:
protected void uxItemsGV_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = uxItemsGV.Rows[e.RowIndex];
try
{
BVController.Updateitem(int.Parse(row.Cells[1].Text), Session["CategoryID"].ToString(), ((TextBox)row.Cells[2].Controls[0]).Text.Trim(),
int.Parse(((TextBox)row.Cells[3].Controls[0]).Text.Trim()), decimal.Parse(((TextBox)row.Cells[5].Controls[0]).Text.Trim()),
int.Parse(((TextBox)row.Cells[4].Controls[0]).Text.Trim()));
uxUserMessage.Text = "Item " + row.Cells[1].Text + " has been updated.";
}
catch (Exception ex)
{
uxUserMessage.Text = "The following error occured: " + ex.Message;
MsgBlock.Visible = true;
}
}
Когда я нажал на ссылку обновления, код сказал, что обновление выполнено, но никаких изменений не было сделано. Я установил точку останова и обнаружил, что код просто передает старые значения, чтобы зафиксировать обновление. Никаких новых ценностей не будет. Любое предложение? Спасибо!