'Quantity'라는 텍스트 상자 열이있는 gridview가 있습니다. 이제는 열의 텍스트가 변경되면 이벤트 핸들러를 실행하려고합니다. 이것은 Text_ChangedEvent 이벤트 핸들러입니다OnTextChanged 이벤트가 실행되지 않습니다.
<asp:GridView ID="GridView_Products" runat="server" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3"
HorizontalAlign="Center" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox ID="Textbox_Quantity" runat="server" Width="30px" OnTextChanged="Text_ChangedEvent"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<img src="Images/<%# Eval("Image_URL") %>" width="80" height="100" alt="Image" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White"
HorizontalAlign="Center" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
:
protected void Text_ChangedEvent(object sender, EventArgs e)
{
Validation val = new Validation();
TextBox textbox_quantity = ((TextBox)(sender));
GridViewRow row = ((GridViewRow)(textbox_quantity.NamingContainer));
if (textbox_quantity.Text.Equals("0") == true)
{
Label_Error.Visible = true;
Label_Error.Text = "Error Message: The quantity cannot be 0!";
}
else
{
if (val.IsNumeric(textbox_quantity.Text) == false)
{
Label_Error.Visible = true;
Label_Error.Text = "Error Message: The quantity must be numeric!";
}
else
{
total = total + (Convert.ToDouble(textbox_quantity.Text) * Convert.ToDouble(row.Cells[5].Text));
transaction.Add(textbox_quantity.Text);
}
}
}
왜 이벤트 처리기가 실행되지
이는있는 gridview에 대한 코드?
제목을 편집했습니다. "[제목에"태그 "가 포함되어 있어야합니까?] (http://meta.stackexchange.com/questions/19190/)"합의가 "아니오, 그렇지 않아야한다"는 것을 참조하십시오. –